Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Add after destroy hook #59

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
...
en
```

## 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 @@ -91,6 +91,7 @@ def friends_with?(friend)
def on_friendship_created(*args); end
def on_friendship_accepted(*args); end
def on_friendship_blocked(*args); end
def on_friendship_destroyed(*args); end

private

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