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.



27154
27155
27156
27157
27158
27159
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 27154

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.



27152
27153
27154
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 27152

def experiments
  @experiments
end

#idObject (readonly)

Returns the value of attribute id.



27152
27153
27154
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 27152

def id
  @id
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



27165
27166
27167
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 27165

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

#to_hashObject



27169
27170
27171
27172
27173
27174
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 27169

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

#to_jsonObject



27161
27162
27163
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 27161

def to_json
  JSON.dump(to_hash)
end