Class: Mumuki::Domain::Submission::Try

Inherits:
ConsoleSubmission show all
Defined in:
lib/mumuki/domain/submission/try.rb

Constant Summary

Constants inherited from Base

Base::ATTRIBUTES

Instance Attribute Summary collapse

Attributes inherited from Base

#client_result

Instance Method Summary collapse

Methods inherited from ConsoleSubmission

#format_query_result!, #try_evaluate!

Methods inherited from Base

#dry_run!, #evaluate!, from_attributes, #id, mapping_attributes, #run!, #with_client_result

Instance Attribute Details

Returns the value of attribute cookie.



2
3
4
# File 'lib/mumuki/domain/submission/try.rb', line 2

def cookie
  @cookie
end

#queryObject

Returns the value of attribute query.



2
3
4
# File 'lib/mumuki/domain/submission/try.rb', line 2

def query
  @query
end

Instance Method Details

#save_results!(results, assignment) ⇒ Object



15
16
17
18
19
20
# File 'lib/mumuki/domain/submission/try.rb', line 15

def save_results!(results, assignment)
  changes = { status: results[:status], result: results[:result] }
  changes.merge! query_results: assignment.query_results.insert_last(results[:query_result]) if results[:query_result]

  assignment.update! changes
end

#save_submission!(assignment) ⇒ Object



8
9
10
11
12
13
# File 'lib/mumuki/domain/submission/try.rb', line 8

def save_submission!(assignment)
  assignment.query_results = [] if cookie.blank?
  assignment.queries = cookie.insert_last(query)
  assignment.save_submission! self
  assignment.save!
end

#try_evaluate_query!(assignment) ⇒ Object



4
5
6
# File 'lib/mumuki/domain/submission/try.rb', line 4

def try_evaluate_query!(assignment)
  assignment.run_try!(query: query, cookie: cookie).except(:response_type)
end