Class: Ratable::RatingAverage

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Model
Defined in:
app/models/ratable/rating_average.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ RatingAverage

Returns a new instance of RatingAverage.



7
8
9
10
11
# File 'app/models/ratable/rating_average.rb', line 7

def initialize(attributes={})
  attributes.reject! { |k| k == :value }
  attributes.each { |k,v| send("#{k}=", v) }
  @value = @ratings.average(:value).to_i
end

Instance Attribute Details

#rateeObject

Returns the value of attribute ratee.



5
6
7
# File 'app/models/ratable/rating_average.rb', line 5

def ratee
  @ratee
end

#raterObject

Returns the value of attribute rater.



5
6
7
# File 'app/models/ratable/rating_average.rb', line 5

def rater
  @rater
end

#ratingsObject

Returns the value of attribute ratings.



5
6
7
# File 'app/models/ratable/rating_average.rb', line 5

def ratings
  @ratings
end

#valueObject

Returns the value of attribute value.



5
6
7
# File 'app/models/ratable/rating_average.rb', line 5

def value
  @value
end