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.



13349
13350
13351
13352
13353
13354
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13349

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.



13347
13348
13349
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13347

def id
  @id
end

#keyObject (readonly)

Returns the value of attribute key.



13347
13348
13349
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13347

def key
  @key
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



13360
13361
13362
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13360

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

#to_hashObject



13364
13365
13366
13367
13368
13369
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13364

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

#to_jsonObject



13356
13357
13358
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13356

def to_json
  JSON.dump(to_hash)
end