Class: Unleash::ActivationStrategy
- Inherits:
-
Object
- Object
- Unleash::ActivationStrategy
- Defined in:
- lib/unleash/activation_strategy.rb
Instance Attribute Summary collapse
-
#constraints ⇒ Object
Returns the value of attribute constraints.
-
#disabled ⇒ Object
Returns the value of attribute disabled.
-
#name ⇒ Object
Returns the value of attribute name.
-
#params ⇒ Object
Returns the value of attribute params.
-
#variant_definitions ⇒ Object
Returns the value of attribute variant_definitions.
Instance Method Summary collapse
-
#initialize(name, params, constraints = [], variant_definitions = []) ⇒ ActivationStrategy
constructor
A new instance of ActivationStrategy.
- #matches_context?(context) ⇒ Boolean
Constructor Details
#initialize(name, params, constraints = [], variant_definitions = []) ⇒ ActivationStrategy
Returns a new instance of ActivationStrategy.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/unleash/activation_strategy.rb', line 5 def initialize(name, params, constraints = [], variant_definitions = []) self.name = name self.disabled = false if params.is_a?(Hash) self.params = params elsif params.nil? self.params = {} else Unleash.logger.warn "Invalid params provided for ActivationStrategy (params:#{params})" self.params = {} end if constraints.is_a?(Array) && constraints.all?{ |c| c.is_a?(Constraint) } self.constraints = constraints else Unleash.logger.warn "Invalid constraints provided for ActivationStrategy (constraints: #{constraints})" self.disabled = true self.constraints = [] end self.variant_definitions = valid_variant_definitions(variant_definitions) end |
Instance Attribute Details
#constraints ⇒ Object
Returns the value of attribute constraints.
3 4 5 |
# File 'lib/unleash/activation_strategy.rb', line 3 def constraints @constraints end |
#disabled ⇒ Object
Returns the value of attribute disabled.
3 4 5 |
# File 'lib/unleash/activation_strategy.rb', line 3 def disabled @disabled end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/unleash/activation_strategy.rb', line 3 def name @name end |
#params ⇒ Object
Returns the value of attribute params.
3 4 5 |
# File 'lib/unleash/activation_strategy.rb', line 3 def params @params end |
#variant_definitions ⇒ Object
Returns the value of attribute variant_definitions.
3 4 5 |
# File 'lib/unleash/activation_strategy.rb', line 3 def variant_definitions @variant_definitions end |
Instance Method Details
#matches_context?(context) ⇒ Boolean
29 30 31 |
# File 'lib/unleash/activation_strategy.rb', line 29 def matches_context?(context) self.constraints.any?{ |c| c.matches_context? context } end |