Skip to content

Commit

Permalink
Create .on_friendship_destroyed callback
Browse files Browse the repository at this point in the history
  • Loading branch information
skycocker committed Jun 2, 2018
1 parent 85e9c0b commit 81fe22a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@ end
def on_friendship_blocked(friendship)
...
end

def on_friendship_destroyed(friendship)
...
end
```

## Roadmap
Expand Down
1 change: 1 addition & 0 deletions lib/has_friendship/friendable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ module InstanceMethods
on_friendship_created
on_friendship_accepted
on_friendship_blocked
on_friendship_destroyed
).freeze

CALLBACK_METHOD_NAMES.each do |method_name|
Expand Down
4 changes: 4 additions & 0 deletions lib/has_friendship/friendship.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ class Friendship < ActiveRecord::Base
friend.on_friendship_created(self)
end

after_destroy do
friend.on_friendship_destroyed(self)
end

enum status: { pending: 0, requested: 1, accepted: 2, blocked: 3 } do
event :accept do
transition [:pending, :requested] => :accepted
Expand Down

0 comments on commit 81fe22a

Please sign in to comment.