Class: Rating
- Inherits:
-
Object
- Object
- Rating
- Includes:
- ActiveModel::Serialization
- Defined in:
- app/models/rating.rb
Instance Attribute Summary collapse
-
#object ⇒ Object
readonly
Returns the value of attribute object.
Delegated Instance Attributes collapse
-
#cache_key ⇒ Object
Alias for Object#cache_key.
Instance Method Summary collapse
- #avg_stars ⇒ Object
-
#initialize(product_review_info, object = nil) ⇒ Rating
constructor
A new instance of Rating.
- #product_reviews ⇒ Object
- #review_count ⇒ Object
Constructor Details
#initialize(product_review_info, object = nil) ⇒ Rating
Returns a new instance of Rating.
9 10 11 12 |
# File 'app/models/rating.rb', line 9 def initialize(product_review_info, object = nil) @product_review_info = product_review_info @object = object end |
Instance Attribute Details
#object ⇒ Object (readonly)
Returns the value of attribute object.
5 6 7 |
# File 'app/models/rating.rb', line 5 def object @object end |
Instance Method Details
#avg_stars ⇒ Object
14 15 16 |
# File 'app/models/rating.rb', line 14 def avg_stars @product_review_info[:star_avg] end |
#cache_key ⇒ Object
Alias for Object#cache_key
7 |
# File 'app/models/rating.rb', line 7 delegate :cache_key, to: :object |
#product_reviews ⇒ Object
22 23 24 |
# File 'app/models/rating.rb', line 22 def product_reviews @product_review_info[:reviews] end |
#review_count ⇒ Object
18 19 20 |
# File 'app/models/rating.rb', line 18 def review_count @product_review_info[:num] end |