Module: Rateable::IsRateable::InstanceMethods
- Defined in:
- lib/rateable/is_rateable.rb
Instance Method Summary collapse
- #is_rateable? ⇒ Boolean
- #max_stars ⇒ Object
-
#rate(user, stars) ⇒ Object
include instance methods that are needed.
Instance Method Details
#is_rateable? ⇒ Boolean
26 27 28 |
# File 'lib/rateable/is_rateable.rb', line 26 def is_rateable? true end |
#max_stars ⇒ Object
30 31 32 |
# File 'lib/rateable/is_rateable.rb', line 30 def max_stars self.class.max_stars end |
#rate(user, stars) ⇒ Object
include instance methods that are needed
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/rateable/is_rateable.rb', line 35 def rate(user,stars) raise "#{user.inspect} is not a rater" unless user.respond_to?(:is_rater?) and user.is_rater? = Rate.where(:rateable => self, :rater => user).first unless = Rate.create(:rateable => self, :rater => user, :stars => stars) else .stars = stars end .save end |