Class: Shark::SurveyParticipant
- Extended by:
- Shark::SurveyService::Resource
- Defined in:
- lib/shark/survey_participant.rb
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Base
Class Method Details
.create(attributes) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/shark/survey_participant.rb', line 17 def self.create(attributes) attributes_copy = attributes.symbolize_keys survey_id = attributes_copy.delete(:survey_id) raise ArgumentError, 'Missing attribute :survey_id' unless survey_id participant = new(attributes_copy) participant.relationships.survey = { data: { id: survey_id } } participant.save participant end |
.find(*args) ⇒ Object
13 14 15 |
# File 'lib/shark/survey_participant.rb', line 13 def self.find(*args) super.first end |
.table_name ⇒ Object
9 10 11 |
# File 'lib/shark/survey_participant.rb', line 9 def self.table_name 'participants' end |
Instance Method Details
#participate ⇒ Object
33 34 35 |
# File 'lib/shark/survey_participant.rb', line 33 def participate update(state: 'participated') end |
#participated? ⇒ Boolean
29 30 31 |
# File 'lib/shark/survey_participant.rb', line 29 def participated? state == 'participated' end |