Module: ActiveRecord::Acts::MuckFriend::InstanceMethods
- Defined in:
- lib/active_record/acts/muck_friend.rb
Overview
All the methods available to a record that has had acts_as_muck_friend
specified.
Instance Method Summary collapse
-
#add_follow_activity ⇒ Object
Add activity that indicates user is following another user.
-
#add_friends_with_activity ⇒ Object
Add an activity that indicates the users have become friends.
- #after_create ⇒ Object
- #block ⇒ Object
- #blocked? ⇒ Boolean
- #unblock ⇒ Object
- #validate ⇒ Object
Instance Method Details
#add_follow_activity ⇒ Object
Add activity that indicates user is following another user
150 151 152 153 154 |
# File 'lib/active_record/acts/muck_friend.rb', line 150 def add_follow_activity return unless GlobalConfig.enable_friend_activity content = I18n.t('muck.friends.follow_activity', :inviter => self.inviter.full_name, :invited => self.invited.full_name) add_activity(self.inviter.feed_to, self.inviter, self, 'follow', '', content) end |
#add_friends_with_activity ⇒ Object
Add an activity that indicates the users have become friends
157 158 159 160 161 |
# File 'lib/active_record/acts/muck_friend.rb', line 157 def add_friends_with_activity return unless GlobalConfig.enable_friend_activity content = I18n.t('muck.friends.friends_with', :inviter => self.inviter.full_name, :invited => self.invited.full_name) add_activity(self.inviter.feed_to + self.invited.feed_to, self.inviter, self, 'friends_with', '', content) end |
#after_create ⇒ Object
130 131 132 |
# File 'lib/active_record/acts/muck_friend.rb', line 130 def after_create FriendMailer.deliver_follow(inviter, invited) end |
#block ⇒ Object
134 135 136 |
# File 'lib/active_record/acts/muck_friend.rb', line 134 def block self.update_attribute(:status, MuckFriends::BLOCKED) end |
#blocked? ⇒ Boolean
142 143 144 145 146 147 |
# File 'lib/active_record/acts/muck_friend.rb', line 142 def blocked? # TODO status is a reserved word in mysql. self.status won't work here (just returns nil). # Consider setting up 'friend' to use a state machine instead of numeric values # doing so would cleanup transitions between states. self[:status] == MuckFriends::BLOCKED end |
#unblock ⇒ Object
138 139 140 |
# File 'lib/active_record/acts/muck_friend.rb', line 138 def unblock self.update_attribute(:status, MuckFriends::FOLLOWING) end |
#validate ⇒ Object
163 164 165 |
# File 'lib/active_record/acts/muck_friend.rb', line 163 def validate errors.add('inviter', I18n.t('muck.friends.same_inviter_error_message')) if invited == inviter end |