Module: Adventtec::Acts::Likable::InstanceMethods
- Defined in:
- lib/movr_acts_as_likeable.rb
Overview
This module contains instance methods
Instance Method Summary collapse
- #liked_by_user?(user = nil) ⇒ Boolean
-
#likes_count ⇒ Object
Same as likable.likes.size.
- #users_who_liked ⇒ Object
Instance Method Details
#liked_by_user?(user = nil) ⇒ Boolean
41 42 43 44 45 46 |
# File 'lib/movr_acts_as_likeable.rb', line 41 def liked_by_user?(user = nil) if not user user = current_user end user && self.likes.first(:conditions => {:user_id => user.id}) end |
#likes_count ⇒ Object
Same as likable.likes.size
33 34 35 |
# File 'lib/movr_acts_as_likeable.rb', line 33 def likes_count self.likes.count end |
#users_who_liked ⇒ Object
37 38 39 |
# File 'lib/movr_acts_as_likeable.rb', line 37 def users_who_liked self.likes.find(:all, :include => [:user]).map(&:user) end |