lib/popular/popular.rb in popular-0.5.0 vs lib/popular/popular.rb in popular-0.5.1
- old
+ new
@@ -66,9 +66,29 @@
run_callbacks :unfriend do
friendships.where( friend: friend ).first.destroy
end
end
+ # Helper method for determining whether instances are mutual friends
+ #
+ # @param [Object] popular_model
+ # @return [Boolean] if both instances have befriended eachother
+ #
+ # @example
+ # user = User.create name: "Justin"
+ # other_user = User.create name: "Jenny"
+ #
+ # user.befriend other_user
+ # other_user.befriend user
+ #
+ # user.mutual_friends_with? other_user #=> true
+ def mutual_friends_with? popular_model
+ friends_with?( popular_model ) && friended_by?( popular_model )
+ end
+
+ # Helper method for finding whether or not the instance has befriended
+ # another given popular_model
+ #
# Helper method for finding whether or not the instance has
# been befriended by another given popular_model
#
# @param [Object] popular_model
# @return [Boolean] if the instance has been friended by another popular_model