Class: Orias::Response
Overview
Dedicated to search response handling
Constant Summary collapse
- VALID_TYPES =
[:intermediary_search].freeze
Instance Attribute Summary collapse
-
#raw ⇒ Object
Returns the value of attribute raw.
-
#raw_hash ⇒ Object
Returns the value of attribute raw_hash.
-
#results ⇒ Object
Returns the value of attribute results.
-
#type ⇒ Object
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ Response
constructor
Initialize an Orias::Response instance.
Constructor Details
#initialize(attributes = {}) ⇒ Response
Initialize an Orias::Response instance
12 13 14 15 16 |
# File 'lib/orias/response.rb', line 12 def initialize(attributes = {}) super self.process_raw_response! if results.nil? self.check_type end |
Instance Attribute Details
#raw ⇒ Object
Returns the value of attribute raw.
9 10 11 |
# File 'lib/orias/response.rb', line 9 def raw @raw end |
#raw_hash ⇒ Object
Returns the value of attribute raw_hash.
9 10 11 |
# File 'lib/orias/response.rb', line 9 def raw_hash @raw_hash end |
#results ⇒ Object
Returns the value of attribute results.
9 10 11 |
# File 'lib/orias/response.rb', line 9 def results @results end |
#type ⇒ Object
Returns the value of attribute type.
9 10 11 |
# File 'lib/orias/response.rb', line 9 def type @type end |
Class Method Details
.merge(instances) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/orias/response.rb', line 59 def merge(instances) if instances.map(&:type).uniq.compact.length != 1 raise 'Orias::Response - Error merging Orias::Response collection.' end self.new( raw: instances.map(&:raw), raw_hash: instances.map(&:raw_hash), results: instances.map(&:results).flatten, type: instances.map(&:type).uniq.first ) end |