Class: Io::Flow::V0::Models::Experiment

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

Overview

Represents a single experiment / test (e.g. for an incremental rollout or AB Test)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ Experiment

Returns a new instance of Experiment.



14335
14336
14337
14338
14339
14340
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14335

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :key], 'Experiment')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
  @key = HttpClient::Preconditions.assert_class('key', opts.delete(:key), String)
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



14333
14334
14335
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14333

def id
  @id
end

#keyObject (readonly)

Returns the value of attribute key.



14333
14334
14335
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14333

def key
  @key
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



14346
14347
14348
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14346

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

#to_hashObject



14350
14351
14352
14353
14354
14355
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14350

def to_hash
  {
    :id => id,
    :key => key
  }
end

#to_jsonObject



14342
14343
14344
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14342

def to_json
  JSON.dump(to_hash)
end