Class: Mixpanel::Flags::FallbackReason
- Inherits:
-
Object
- Object
- Mixpanel::Flags::FallbackReason
- Defined in:
- lib/mixpanel-ruby/flags/types.rb
Overview
Why the SDK returned the developer fallback. Only meaningful when SelectedVariant#variant_source == VariantSource::FALLBACK.
kind is the discriminator (matches the PHP constant set). message
is set on the reasons that carry useful detail (BACKEND_ERROR with the
backend's response, MISSING_CONTEXT_KEY with the missing attribute);
nil otherwise. The OpenFeature wrapper dispatches on kind and forwards
message into ResolutionDetails#error_message.
Constant Summary collapse
- KINDS =
%i[flag_not_found missing_context_key no_rollout_match backend_error].freeze
- FLAG_NOT_FOUND =
new(:flag_not_found)
- NO_ROLLOUT_MATCH =
new(:no_rollout_match)
Instance Attribute Summary collapse
-
#kind ⇒ Object
readonly
Returns the value of attribute kind.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
Class Method Summary collapse
- .backend_error(message) ⇒ Object
-
.flag_not_found ⇒ Object
Factory methods.
- .missing_context_key(key = nil) ⇒ Object
- .no_rollout_match ⇒ Object
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(kind, message: nil) ⇒ FallbackReason
constructor
A new instance of FallbackReason.
- #to_h ⇒ Object
Constructor Details
#initialize(kind, message: nil) ⇒ FallbackReason
Returns a new instance of FallbackReason.
25 26 27 28 29 30 31 |
# File 'lib/mixpanel-ruby/flags/types.rb', line 25 def initialize(kind, message: nil) raise ArgumentError, "Unknown FallbackReason kind: #{kind.inspect}" unless KINDS.include?(kind) @kind = kind @message = freeze end |
Instance Attribute Details
#kind ⇒ Object (readonly)
Returns the value of attribute kind.
23 24 25 |
# File 'lib/mixpanel-ruby/flags/types.rb', line 23 def kind @kind end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
23 24 25 |
# File 'lib/mixpanel-ruby/flags/types.rb', line 23 def @message end |
Class Method Details
.backend_error(message) ⇒ Object
51 |
# File 'lib/mixpanel-ruby/flags/types.rb', line 51 def self.backend_error(); new(:backend_error, message: ); end |
.flag_not_found ⇒ Object
Factory methods. Reasons without meaningful detail return a frozen singleton; reasons with detail allocate per call.
48 |
# File 'lib/mixpanel-ruby/flags/types.rb', line 48 def self.flag_not_found; FLAG_NOT_FOUND; end |
.missing_context_key(key = nil) ⇒ Object
50 |
# File 'lib/mixpanel-ruby/flags/types.rb', line 50 def self.missing_context_key(key = nil); new(:missing_context_key, message: key); end |
.no_rollout_match ⇒ Object
49 |
# File 'lib/mixpanel-ruby/flags/types.rb', line 49 def self.no_rollout_match; NO_ROLLOUT_MATCH; end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
33 34 35 |
# File 'lib/mixpanel-ruby/flags/types.rb', line 33 def ==(other) other.is_a?(FallbackReason) && other.kind == @kind && other. == @message end |
#hash ⇒ Object
38 39 40 |
# File 'lib/mixpanel-ruby/flags/types.rb', line 38 def hash [self.class, @kind, @message].hash end |
#to_h ⇒ Object
42 43 44 |
# File 'lib/mixpanel-ruby/flags/types.rb', line 42 def to_h { kind: @kind, message: @message }.compact end |