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.



13395
13396
13397
13398
13399
13400
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13395

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.



13393
13394
13395
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13393

def id
  @id
end

#keyObject (readonly)

Returns the value of attribute key.



13393
13394
13395
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13393

def key
  @key
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



13406
13407
13408
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13406

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

#to_hashObject



13410
13411
13412
13413
13414
13415
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13410

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

#to_jsonObject



13402
13403
13404
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13402

def to_json
  JSON.dump(to_hash)
end