diff --git a/README.md b/README.md index 7b67a09..9dc1d26 100644 --- a/README.md +++ b/README.md @@ -92,6 +92,10 @@ remove friendship to the one that initially blocked it. ```ruby # Check if there is an accepted friendship between @mac and @dee @mac.friends_with?(@dee) + +# Check the status between two friends +@mac.friendship_status(@dee) # => "pending" + ``` ### Type of friends diff --git a/lib/has_friendship/friendable.rb b/lib/has_friendship/friendable.rb index bc0035f..f83a89a 100644 --- a/lib/has_friendship/friendable.rb +++ b/lib/has_friendship/friendable.rb @@ -87,6 +87,11 @@ def on_relation_with(friend) def friends_with?(friend) HasFriendship::Friendship.find_relation(self, friend, status: 2).any? end + + def friendship_status(friend) + friendship = HasFriendship::Friendship.find_relation(self, friend) + friendship.first.status if friendship.any? + end def on_friendship_created(*args); end def on_friendship_accepted(*args); end