Class: Io::Flow::V0::Models::SessionExperiment

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

Overview

Experiment for A/B testing

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ SessionExperiment

Returns a new instance of SessionExperiment.



30223
30224
30225
30226
30227
30228
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30223

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:key], 'SessionExperiment')
  @key = HttpClient::Preconditions.assert_class('key', opts.delete(:key), String)
  @variant = (x = opts.delete(:variant); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::SessionExperimentVariant) ? x : ::Io::Flow::V0::Models::SessionExperimentVariant.new(x)))
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



30221
30222
30223
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30221

def key
  @key
end

#variantObject (readonly)

Returns the value of attribute variant.



30221
30222
30223
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30221

def variant
  @variant
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



30234
30235
30236
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30234

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

#to_hashObject



30238
30239
30240
30241
30242
30243
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30238

def to_hash
  {
    :key => key,
    :variant => variant.nil? ? nil : variant.to_hash
  }
end

#to_jsonObject



30230
30231
30232
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30230

def to_json
  JSON.dump(to_hash)
end