Class: Quby::Answers::Repos::Base
- Inherits:
-
Object
- Object
- Quby::Answers::Repos::Base
- Defined in:
- lib/quby/answers/repos/base.rb
Direct Known Subclasses
Instance Method Summary collapse
- #all(questionnaire_key) ⇒ Object
- #create!(answer) ⇒ Object
- #find(questionnaire_key, answer_id, **options) ⇒ Object
- #reload(answer) ⇒ Object
- #update!(answer) ⇒ Object
Instance Method Details
#all(questionnaire_key) ⇒ Object
17 18 19 20 |
# File 'lib/quby/answers/repos/base.rb', line 17 def all(questionnaire_key) records = all_records(questionnaire_key) entities(records) end |
#create!(answer) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/quby/answers/repos/base.rb', line 22 def create!(answer) record = build_record record.questionnaire_key = answer.questionnaire_key update_attributes(record, answer) store_record(record) entity(record) end |
#find(questionnaire_key, answer_id, **options) ⇒ Object
7 8 9 10 11 |
# File 'lib/quby/answers/repos/base.rb', line 7 def find(questionnaire_key, answer_id, **) record = find_record(answer_id) fail AnswerNotFound, "Answer #{answer_id.inspect} could not be found." unless record.present? entity(record) end |
#reload(answer) ⇒ Object
13 14 15 |
# File 'lib/quby/answers/repos/base.rb', line 13 def reload(answer) find(answer.questionnaire_key, answer.id) end |
#update!(answer) ⇒ Object
30 31 32 33 34 |
# File 'lib/quby/answers/repos/base.rb', line 30 def update!(answer) record = find_record(answer.id) update_attributes(record, answer) store_record(record) end |