Class: Unleash::VariantDefinition
- Inherits:
-
Object
- Object
- Unleash::VariantDefinition
- Defined in:
- lib/unleash/variant_definition.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#overrides ⇒ Object
Returns the value of attribute overrides.
-
#payload ⇒ Object
Returns the value of attribute payload.
-
#stickiness ⇒ Object
Returns the value of attribute stickiness.
-
#weight ⇒ Object
Returns the value of attribute weight.
Instance Method Summary collapse
-
#initialize(name, weight = 0, payload = nil, stickiness = nil, overrides = []) ⇒ VariantDefinition
constructor
rubocop:disable Metrics/ParameterLists.
- #override_matches_context?(context) ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(name, weight = 0, payload = nil, stickiness = nil, overrides = []) ⇒ VariantDefinition
rubocop:disable Metrics/ParameterLists
7 8 9 10 11 12 13 14 15 |
# File 'lib/unleash/variant_definition.rb', line 7 def initialize(name, weight = 0, payload = nil, stickiness = nil, overrides = []) # rubocop:disable Metrics/ParameterLists self.name = name self.weight = weight self.payload = payload self.stickiness = stickiness self.overrides = (overrides || []) .select{ |v| v.is_a?(Hash) && v.has_key?('contextName') } .map{ |v| VariantOverride.new(v.fetch('contextName', ''), v.fetch('values', [])) } || [] end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/unleash/variant_definition.rb', line 5 def name @name end |
#overrides ⇒ Object
Returns the value of attribute overrides.
5 6 7 |
# File 'lib/unleash/variant_definition.rb', line 5 def overrides @overrides end |
#payload ⇒ Object
Returns the value of attribute payload.
5 6 7 |
# File 'lib/unleash/variant_definition.rb', line 5 def payload @payload end |
#stickiness ⇒ Object
Returns the value of attribute stickiness.
5 6 7 |
# File 'lib/unleash/variant_definition.rb', line 5 def stickiness @stickiness end |
#weight ⇒ Object
Returns the value of attribute weight.
5 6 7 |
# File 'lib/unleash/variant_definition.rb', line 5 def weight @weight end |
Instance Method Details
#override_matches_context?(context) ⇒ Boolean
17 18 19 |
# File 'lib/unleash/variant_definition.rb', line 17 def override_matches_context?(context) self.overrides.select{ |o| o.matches_context?(context) }.first end |
#to_s ⇒ Object
21 22 23 24 |
# File 'lib/unleash/variant_definition.rb', line 21 def to_s "<VariantDefinition: name=#{self.name},weight=#{self.weight},payload=#{self.payload},stickiness=#{self.stickiness}" \ ",overrides=#{self.overrides}>" end |