Class: Mixpanel::Flags::SelectedVariant

Inherits:
Object
  • Object
show all
Defined in:
lib/mixpanel-ruby/flags/types.rb

Overview

Selected variant returned from flag evaluation

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(variant_key: nil, variant_value: nil, experiment_id: nil, is_experiment_active: nil, is_qa_tester: nil) ⇒ SelectedVariant

Returns a new instance of SelectedVariant.

Parameters:

  • variant_key (String, nil) (defaults to: nil)

    The variant key

  • variant_value (Object) (defaults to: nil)

    The variant value (any type)

  • experiment_id (String, nil) (defaults to: nil)

    Associated experiment ID

  • is_experiment_active (Boolean, nil) (defaults to: nil)

    Whether experiment is active

  • is_qa_tester (Boolean, nil) (defaults to: nil)

    Whether user is a QA tester



13
14
15
16
17
18
19
20
# File 'lib/mixpanel-ruby/flags/types.rb', line 13

def initialize(variant_key: nil, variant_value: nil, experiment_id: nil,
               is_experiment_active: nil, is_qa_tester: nil)
  @variant_key = variant_key
  @variant_value = variant_value
  @experiment_id = experiment_id
  @is_experiment_active = is_experiment_active
  @is_qa_tester = is_qa_tester
end

Instance Attribute Details

#experiment_idObject

Returns the value of attribute experiment_id.



5
6
7
# File 'lib/mixpanel-ruby/flags/types.rb', line 5

def experiment_id
  @experiment_id
end

#is_experiment_activeObject

Returns the value of attribute is_experiment_active.



5
6
7
# File 'lib/mixpanel-ruby/flags/types.rb', line 5

def is_experiment_active
  @is_experiment_active
end

#is_qa_testerObject

Returns the value of attribute is_qa_tester.



5
6
7
# File 'lib/mixpanel-ruby/flags/types.rb', line 5

def is_qa_tester
  @is_qa_tester
end

#variant_keyObject

Returns the value of attribute variant_key.



5
6
7
# File 'lib/mixpanel-ruby/flags/types.rb', line 5

def variant_key
  @variant_key
end

#variant_valueObject

Returns the value of attribute variant_value.



5
6
7
# File 'lib/mixpanel-ruby/flags/types.rb', line 5

def variant_value
  @variant_value
end

Instance Method Details

#to_hHash

Convert to hash representation

Returns:

  • (Hash)


24
25
26
27
28
29
30
31
32
# File 'lib/mixpanel-ruby/flags/types.rb', line 24

def to_h
  {
    variant_key: @variant_key,
    variant_value: @variant_value,
    experiment_id: @experiment_id,
    is_experiment_active: @is_experiment_active,
    is_qa_tester: @is_qa_tester
  }.compact
end