Class: Io::Flow::V0::Models::Query
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::Query
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Overview
The query model is used to present a query to a user, containing both the raw query as well as the filter representation of the query.
Instance Attribute Summary collapse
-
#filters ⇒ Object
readonly
Returns the value of attribute filters.
-
#q ⇒ Object
readonly
Returns the value of attribute q.
Instance Method Summary collapse
- #copy(incoming = {}) ⇒ Object
-
#initialize(incoming = {}) ⇒ Query
constructor
A new instance of Query.
- #to_hash ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(incoming = {}) ⇒ Query
Returns a new instance of Query.
40341 40342 40343 40344 40345 40346 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40341 def initialize(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) HttpClient::Preconditions.require_keys(opts, [:q, :filters], 'Query') @q = HttpClient::Preconditions.assert_class('q', opts.delete(:q), String) @filters = HttpClient::Preconditions.assert_class('filters', opts.delete(:filters), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::QueryFilter) ? x : ::Io::Flow::V0::Models::QueryFilter.from_json(x)) } end |
Instance Attribute Details
#filters ⇒ Object (readonly)
Returns the value of attribute filters.
40339 40340 40341 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40339 def filters @filters end |
#q ⇒ Object (readonly)
Returns the value of attribute q.
40339 40340 40341 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40339 def q @q end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
40352 40353 40354 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40352 def copy(incoming={}) Query.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#to_hash ⇒ Object
40356 40357 40358 40359 40360 40361 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40356 def to_hash { :q => q, :filters => filters.map { |o| o.to_hash } } end |
#to_json ⇒ Object
40348 40349 40350 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40348 def to_json JSON.dump(to_hash) end |