Class: AmplitudeExperiment::Variant

Inherits:
Object
  • Object
show all
Defined in:
lib/experiment/variant.rb

Overview

Variant

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value: nil, payload: nil, key: nil, metadata: nil) ⇒ Variant

Returns a new instance of Variant.

Parameters:

  • value (String) (defaults to: nil)

    The value of the variant determined by the flag configuration.

  • payload (Object, nil) (defaults to: nil)

    The attached payload, if any.

  • key (String) (defaults to: nil)

    The key of the variant determined by the flag configuration.

  • metadata (Object, nil) (defaults to: nil)

    The attached metadata, if any.



22
23
24
25
26
27
# File 'lib/experiment/variant.rb', line 22

def initialize(value: nil, payload: nil, key: nil, metadata: nil)
  @key = key
  @value = value
  @payload = payload
  @metadata = 
end

Instance Attribute Details

#keyString

The key of the variant determined by the flag configuration.

Returns:

  • (String)

    the value of variant key



6
7
8
# File 'lib/experiment/variant.rb', line 6

def key
  @key
end

#metadataObject

Returns the value of attribute metadata.



16
17
18
# File 'lib/experiment/variant.rb', line 16

def 
  @metadata
end

#payloadObject?

The attached payload, if any.

Returns:

  • (Object, nil)

    the value of variant payload



14
15
16
# File 'lib/experiment/variant.rb', line 14

def payload
  @payload
end

#valueString

The value of the variant determined by the flag configuration.

Returns:

  • (String)

    the value of variant value



10
11
12
# File 'lib/experiment/variant.rb', line 10

def value
  @value
end

Instance Method Details

#==(other) ⇒ Object

Determine if current variant equal other variant

Parameters:



31
32
33
34
# File 'lib/experiment/variant.rb', line 31

def ==(other)
  key == other.key && value == other.value &&
    payload == other.payload
end