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.
Instance Method Summary collapse
-
#initialize(name, params, constraints = []) ⇒ ActivationStrategy
constructor
A new instance of ActivationStrategy.
- #matches_context?(context) ⇒ Boolean
Constructor Details
#initialize(name, params, constraints = []) ⇒ 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 |
# File 'lib/unleash/activation_strategy.rb', line 5 def initialize(name, params, constraints = []) 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.each{ |c| c.is_a?(Constraint) } self.constraints = constraints else Unleash.logger.warn "Invalid constraints provided for ActivationStrategy (contraints: #{constraints})" self.disabled = true self.constraints = [] end 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 |
Instance Method Details
#matches_context?(context) ⇒ Boolean
27 28 29 |
# File 'lib/unleash/activation_strategy.rb', line 27 def matches_context?(context) self.constraints.any?{ |c| c.matches_context? context } end |