Class: Unleash::Variant
- Inherits:
-
Object
- Object
- Unleash::Variant
- Defined in:
- lib/unleash/variant.rb
Instance Attribute Summary collapse
-
#enabled ⇒ Object
Returns the value of attribute enabled.
-
#feature_enabled ⇒ Object
Returns the value of attribute feature_enabled.
-
#name ⇒ Object
Returns the value of attribute name.
-
#payload ⇒ Object
Returns the value of attribute payload.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(params = {}) ⇒ Variant
constructor
A new instance of Variant.
- #to_s ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ Variant
Returns a new instance of Variant.
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/unleash/variant.rb', line 5 def initialize(params = {}) raise ArgumentError, "Variant initializer requires a hash." unless params.is_a?(Hash) self.name = params.values_at('name', :name).compact.first self.enabled = params.values_at('enabled', :enabled).compact.first || false self.payload = params.values_at('payload', :payload).compact.first self.feature_enabled = params.values_at('feature_enabled', :feature_enabled).compact.first || false raise ArgumentError, "Variant requires a name." if self.name.nil? end |
Instance Attribute Details
#enabled ⇒ Object
Returns the value of attribute enabled.
3 4 5 |
# File 'lib/unleash/variant.rb', line 3 def enabled @enabled end |
#feature_enabled ⇒ Object
Returns the value of attribute feature_enabled.
3 4 5 |
# File 'lib/unleash/variant.rb', line 3 def feature_enabled @feature_enabled end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/unleash/variant.rb', line 3 def name @name end |
#payload ⇒ Object
Returns the value of attribute payload.
3 4 5 |
# File 'lib/unleash/variant.rb', line 3 def payload @payload end |
Class Method Details
Instance Method Details
#==(other) ⇒ Object
22 23 24 25 |
# File 'lib/unleash/variant.rb', line 22 def ==(other) self.name == other.name && self.enabled == other.enabled && self.payload == other.payload \ && self.feature_enabled == other.feature_enabled end |
#to_s ⇒ Object
16 17 18 19 20 |
# File 'lib/unleash/variant.rb', line 16 def to_s # :nocov: "<Variant: name=#{self.name},enabled=#{self.enabled},payload=#{self.payload},feature_enabled=#{self.feature_enabled}>" # :nocov: end |