Class: GeoLabels::RatingObject

Inherits:
Object
  • Object
show all
Defined in:
app/models/concerns/geo_labels/ratings_support.rb

Overview

Represent the rating of one topic as an object

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(record, topic) ⇒ RatingObject

Returns a new instance of RatingObject.



10
11
12
# File 'app/models/concerns/geo_labels/ratings_support.rb', line 10

def initialize(record, topic)
  @record, @topic = record, topic
end

Instance Attribute Details

#recordObject (readonly)

Returns the value of attribute record.



8
9
10
# File 'app/models/concerns/geo_labels/ratings_support.rb', line 8

def record
  @record
end

#topicObject (readonly)

Returns the value of attribute topic.



8
9
10
# File 'app/models/concerns/geo_labels/ratings_support.rb', line 8

def topic
  @topic
end

Instance Method Details

#valueObject



14
15
16
17
# File 'app/models/concerns/geo_labels/ratings_support.rb', line 14

def value
  # expect active_record column attribute
  record.public_send("#{topic}_rating")
end

#value=(value) ⇒ Object



19
20
21
# File 'app/models/concerns/geo_labels/ratings_support.rb', line 19

def value=(value)
  record.public_send("#{topic}_rating=", value)
end