Class: Choice

Inherits:
ApplicationRecord show all
Defined in:
app/models/choice.rb

Overview

Model to represent choices in a rating scale

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApplicationRecord

#==

Class Method Details

.load_choice(response_scale, choice) ⇒ Object


41
42
43
44
# File 'app/models/choice.rb', line 41

def self.load_choice(response_scale, choice)
  Choice.create_with(description: choice['text']) \
        .find_or_create_by(response_scale: response_scale, value: choice['value'])
end

Instance Method Details

#to_sObject


46
47
48
# File 'app/models/choice.rb', line 46

def to_s
  %(#{response_scale} #{value} #{description})
end