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.



15398
15399
15400
15401
15402
15403
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15398

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.



15396
15397
15398
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15396

def id
  @id
end

#keyObject (readonly)

Returns the value of attribute key.



15396
15397
15398
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15396

def key
  @key
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



15409
15410
15411
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15409

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

#to_hashObject



15413
15414
15415
15416
15417
15418
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15413

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

#to_jsonObject



15405
15406
15407
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15405

def to_json
  JSON.dump(to_hash)
end