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.



37010
37011
37012
37013
37014
37015
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37010

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.



37008
37009
37010
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37008

def experiments
  @experiments
end

#idObject (readonly)

Returns the value of attribute id.



37008
37009
37010
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37008

def id
  @id
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



37021
37022
37023
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37021

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

#to_hashObject



37025
37026
37027
37028
37029
37030
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37025

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

#to_jsonObject



37017
37018
37019
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37017

def to_json
  JSON.dump(to_hash)
end