Class: Mixpanel::Flags::SelectedVariant
- Inherits:
-
Object
- Object
- Mixpanel::Flags::SelectedVariant
- Defined in:
- lib/mixpanel-ruby/flags/types.rb
Overview
Selected variant returned from flag evaluation
Instance Attribute Summary collapse
-
#experiment_id ⇒ Object
Returns the value of attribute experiment_id.
-
#fallback_reason ⇒ Object
Returns the value of attribute fallback_reason.
-
#is_experiment_active ⇒ Object
Returns the value of attribute is_experiment_active.
-
#is_qa_tester ⇒ Object
Returns the value of attribute is_qa_tester.
-
#variant_key ⇒ Object
Returns the value of attribute variant_key.
-
#variant_source ⇒ Object
Returns the value of attribute variant_source.
-
#variant_value ⇒ Object
Returns the value of attribute variant_value.
Instance Method Summary collapse
-
#as_fallback(reason) ⇒ Object
Return a copy tagged as a fallback with the given reason.
-
#initialize(variant_key: nil, variant_value: nil, experiment_id: nil, is_experiment_active: nil, is_qa_tester: nil, variant_source: nil, fallback_reason: nil) ⇒ SelectedVariant
constructor
A new instance of SelectedVariant.
-
#to_h ⇒ Object
Convert to hash representation.
-
#with_source(source) ⇒ Object
Return a copy of this variant tagged with the given source.
Constructor Details
#initialize(variant_key: nil, variant_value: nil, experiment_id: nil, is_experiment_active: nil, is_qa_tester: nil, variant_source: nil, fallback_reason: nil) ⇒ SelectedVariant
Returns a new instance of SelectedVariant.
63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/mixpanel-ruby/flags/types.rb', line 63 def initialize(variant_key: nil, variant_value: nil, experiment_id: nil, is_experiment_active: nil, is_qa_tester: nil, variant_source: nil, fallback_reason: 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 @variant_source = variant_source @fallback_reason = fallback_reason end |
Instance Attribute Details
#experiment_id ⇒ Object
Returns the value of attribute experiment_id.
59 60 61 |
# File 'lib/mixpanel-ruby/flags/types.rb', line 59 def experiment_id @experiment_id end |
#fallback_reason ⇒ Object
Returns the value of attribute fallback_reason.
59 60 61 |
# File 'lib/mixpanel-ruby/flags/types.rb', line 59 def fallback_reason @fallback_reason end |
#is_experiment_active ⇒ Object
Returns the value of attribute is_experiment_active.
59 60 61 |
# File 'lib/mixpanel-ruby/flags/types.rb', line 59 def is_experiment_active @is_experiment_active end |
#is_qa_tester ⇒ Object
Returns the value of attribute is_qa_tester.
59 60 61 |
# File 'lib/mixpanel-ruby/flags/types.rb', line 59 def is_qa_tester @is_qa_tester end |
#variant_key ⇒ Object
Returns the value of attribute variant_key.
59 60 61 |
# File 'lib/mixpanel-ruby/flags/types.rb', line 59 def variant_key @variant_key end |
#variant_source ⇒ Object
Returns the value of attribute variant_source.
59 60 61 |
# File 'lib/mixpanel-ruby/flags/types.rb', line 59 def variant_source @variant_source end |
#variant_value ⇒ Object
Returns the value of attribute variant_value.
59 60 61 |
# File 'lib/mixpanel-ruby/flags/types.rb', line 59 def variant_value @variant_value end |
Instance Method Details
#as_fallback(reason) ⇒ Object
Return a copy tagged as a fallback with the given reason.
82 83 84 |
# File 'lib/mixpanel-ruby/flags/types.rb', line 82 def as_fallback(reason) copy_with(variant_source: VariantSource::FALLBACK, fallback_reason: reason) end |
#to_h ⇒ Object
Convert to hash representation
87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/mixpanel-ruby/flags/types.rb', line 87 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, variant_source: @variant_source, fallback_reason: @fallback_reason&.to_h }.compact end |
#with_source(source) ⇒ Object
Return a copy of this variant tagged with the given source. Clears fallback_reason — use #as_fallback when returning a fallback.
77 78 79 |
# File 'lib/mixpanel-ruby/flags/types.rb', line 77 def with_source(source) copy_with(variant_source: source, fallback_reason: nil) end |