Module: Rateme::Macros::RequiredMethods

Defined in:
lib/rateme/macros.rb

Instance Method Summary collapse

Instance Method Details

#rate(value, options = {}) ⇒ Object



31
32
33
# File 'lib/rateme/macros.rb', line 31

def rate(value, options = {})
  ratings.create(options.merge({ :value => value }))
end

#ratingObject



23
24
25
26
27
28
29
# File 'lib/rateme/macros.rb', line 23

def rating
  if (rating = ratings.average(:value))
    rating 
  else                     
    0.to_f                           
  end                                      
end

#rating_rangeObject



35
36
37
# File 'lib/rateme/macros.rb', line 35

def rating_range
  minimum_rating_allowed..maximum_rating_allowed
end