Class: Friendship
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Friendship
- Defined in:
- lib/friendship.rb
Constant Summary collapse
- STATUS_ALREADY_FRIENDS =
constants
1
- STATUS_ALREADY_REQUESTED =
2
- STATUS_IS_YOU =
3
- STATUS_FRIEND_IS_REQUIRED =
4
- STATUS_FRIENDSHIP_ACCEPTED =
5
- STATUS_REQUESTED =
6
- STATUS_FRIENDSHIP_DECLINED =
7
Instance Method Summary collapse
Instance Method Details
#accept! ⇒ Object
42 43 44 45 |
# File 'lib/friendship.rb', line 42 def accept! User.increment_counter(:friends_count, user_id) unless accepted? update_attribute(:status, 'accepted') end |
#accepted? ⇒ Boolean
34 35 36 |
# File 'lib/friendship.rb', line 34 def accepted? status == 'accepted' end |
#pending? ⇒ Boolean
30 31 32 |
# File 'lib/friendship.rb', line 30 def pending? status == 'pending' end |
#requested? ⇒ Boolean
38 39 40 |
# File 'lib/friendship.rb', line 38 def requested? status == 'requested' end |