Class: Quby::Answers::API
- Inherits:
-
Object
- Object
- Quby::Answers::API
- Defined in:
- lib/quby/answers/api.rb
Instance Method Summary collapse
- #all(questionnaire_key) ⇒ Object
- #create!(questionnaire_key, attributes = {}) ⇒ Object
- #find(questionnaire_key, answer_id, options = {}) ⇒ Object
- #find_completed_after(time, answer_ids) ⇒ Object
- #generate_outcome(answer) ⇒ Object
-
#initialize(answer_repo:) ⇒ API
constructor
A new instance of API.
- #regenerate_outcome!(answer) ⇒ Object
- #reload(answer) ⇒ Object
- #update!(answer) ⇒ Object
Constructor Details
#initialize(answer_repo:) ⇒ API
Returns a new instance of API.
6 7 8 |
# File 'lib/quby/answers/api.rb', line 6 def initialize(answer_repo:) @repo = answer_repo end |
Instance Method Details
#all(questionnaire_key) ⇒ Object
22 23 24 |
# File 'lib/quby/answers/api.rb', line 22 def all(questionnaire_key) @repo.all questionnaire_key end |
#create!(questionnaire_key, attributes = {}) ⇒ Object
26 27 28 29 30 |
# File 'lib/quby/answers/api.rb', line 26 def create!(questionnaire_key, attributes = {}) questionnaire = Quby.questionnaires.find(questionnaire_key) answer = Services::BuildAnswer.new(questionnaire, attributes).build @repo.create! answer end |
#find(questionnaire_key, answer_id, options = {}) ⇒ Object
10 11 12 |
# File 'lib/quby/answers/api.rb', line 10 def find(questionnaire_key, answer_id, = {}) @repo.find questionnaire_key, answer_id, end |
#find_completed_after(time, answer_ids) ⇒ Object
14 15 16 |
# File 'lib/quby/answers/api.rb', line 14 def find_completed_after(time, answer_ids) @repo.find_completed_after time, answer_ids end |
#generate_outcome(answer) ⇒ Object
36 37 38 |
# File 'lib/quby/answers/api.rb', line 36 def generate_outcome(answer) Services::OutcomeCalculation.new(answer).calculate end |
#regenerate_outcome!(answer) ⇒ Object
40 41 42 |
# File 'lib/quby/answers/api.rb', line 40 def regenerate_outcome!(answer) Services::OutcomeCalculation.new(answer).update_scores end |
#reload(answer) ⇒ Object
18 19 20 |
# File 'lib/quby/answers/api.rb', line 18 def reload(answer) @repo.reload answer end |
#update!(answer) ⇒ Object
32 33 34 |
# File 'lib/quby/answers/api.rb', line 32 def update!(answer) @repo.update! answer end |