Module: Ratable::Models::Rater
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/ratable/models/rater.rb
Defined Under Namespace
Modules: ActiveRecordExtension, ActiveRecordInclusion
Instance Attribute Summary collapse
Instance Method Summary
collapse
Instance Attribute Details
#has_one ⇒ Object
Returns the value of attribute has_one.
6
7
8
|
# File 'lib/ratable/models/rater.rb', line 6
def has_one
@has_one
end
|
Instance Method Details
#rate(options = {}) ⇒ Object
51
52
53
54
55
56
57
58
|
# File 'lib/ratable/models/rater.rb', line 51
def rate(options={})
options.reject! { |k| k == :rater }
if defined?(rating)
create_rating(options)
else
ratings.create(options)
end
end
|
#ratees ⇒ Object
43
44
45
46
47
48
49
|
# File 'lib/ratable/models/rater.rb', line 43
def ratees
if defined?(rating)
rating.ratee
else
ratings.includes(:ratee).collect { |rating| rating.ratee }
end
end
|
#rating_average ⇒ Object
35
36
37
38
39
40
41
|
# File 'lib/ratable/models/rater.rb', line 35
def rating_average
if defined?(rating)
::Ratable::RatingAverage.new(ratings: rating, rater: self)
else
::Ratable::RatingAverage.new(ratings: ratings, rater: self)
end
end
|