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.



35812
35813
35814
35815
35816
35817
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35812

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.



35810
35811
35812
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35810

def key
  @key
end

#variantObject (readonly)

Returns the value of attribute variant.



35810
35811
35812
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35810

def variant
  @variant
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



35823
35824
35825
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35823

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

#to_hashObject



35827
35828
35829
35830
35831
35832
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35827

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

#to_jsonObject



35819
35820
35821
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35819

def to_json
  JSON.dump(to_hash)
end