Class: Io::Flow::V0::Models::Context

Inherits:
Object
  • Object
show all
Defined in:
lib/flow_commerce/flow_api_v0_client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ Context

Returns a new instance of Context.



27731
27732
27733
27734
27735
27736
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 27731

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :experiments], 'Context')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
  @experiments = HttpClient::Preconditions.assert_class('experiments', opts.delete(:experiments), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::SessionContextExperiment) ? x : ::Io::Flow::V0::Models::SessionContextExperiment.new(x)) }
end

Instance Attribute Details

#experimentsObject (readonly)

Returns the value of attribute experiments.



27729
27730
27731
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 27729

def experiments
  @experiments
end

#idObject (readonly)

Returns the value of attribute id.



27729
27730
27731
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 27729

def id
  @id
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



27742
27743
27744
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 27742

def copy(incoming={})
  Context.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming)))
end

#to_hashObject



27746
27747
27748
27749
27750
27751
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 27746

def to_hash
  {
    :id => id,
    :experiments => experiments.map { |o| o.to_hash }
  }
end

#to_jsonObject



27738
27739
27740
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 27738

def to_json
  JSON.dump(to_hash)
end