diff --git a/README.md b/README.md index 7b67a09..419c48d 100644 --- a/README.md +++ b/README.md @@ -165,6 +165,10 @@ end def on_friendship_blocked(friendship) ... end + +def on_friendship_destroyed(friendship) + ... +end ``` ## Roadmap diff --git a/lib/has_friendship/friendable.rb b/lib/has_friendship/friendable.rb index 3492a29..10a1a19 100644 --- a/lib/has_friendship/friendable.rb +++ b/lib/has_friendship/friendable.rb @@ -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| diff --git a/lib/has_friendship/friendship.rb b/lib/has_friendship/friendship.rb index 2f717b5..e4bbf04 100644 --- a/lib/has_friendship/friendship.rb +++ b/lib/has_friendship/friendship.rb @@ -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