Module: ActsRateable::LocalInstanceMethods
- Defined in:
- lib/acts_rateable/acts_rateable.rb
Instance Method Summary collapse
-
#has_rated?(resource) ⇒ Boolean
Checks wheter a user rated a resource.
-
#rate(resource, value) ⇒ Object
Rates a resource by an author with a given value.
-
#rated_by?(author) ⇒ Boolean
Checks wheter a resource has been rated by a user.
- #variation(author) ⇒ Object
Instance Method Details
#has_rated?(resource) ⇒ Boolean
Checks wheter a user rated a resource. Returns the rating if true, otherwise returns false.
52 53 54 |
# File 'lib/acts_rateable/acts_rateable.rb', line 52 def has_rated?( resource ) ActsRateable::Rate.rated?(resource, self) end |
#rate(resource, value) ⇒ Object
Rates a resource by an author with a given value.
57 58 59 |
# File 'lib/acts_rateable/acts_rateable.rb', line 57 def rate( resource, value ) ActsRateable::Rate.create(self, resource, value) end |
#rated_by?(author) ⇒ Boolean
Checks wheter a resource has been rated by a user. Returns the rating if true, otherwise returns false.
47 48 49 |
# File 'lib/acts_rateable/acts_rateable.rb', line 47 def rated_by?( ) ActsRateable::Rate.rated?(self, ) end |
#variation(author) ⇒ Object
42 43 44 |
# File 'lib/acts_rateable/acts_rateable.rb', line 42 def variation( ) rated_by?() ? (rated_by?().value/self.['estimate']) : nil end |