Class: Flipflop::Strategies::TestStrategy

Inherits:
AbstractStrategy show all
Defined in:
lib/flipflop/strategies/test_strategy.rb

Constant Summary collapse

@@lock =
Mutex.new

Instance Attribute Summary

Attributes inherited from AbstractStrategy

#description, #key, #name, #title

Instance Method Summary collapse

Methods inherited from AbstractStrategy

default_description, default_name, #hidden?

Constructor Details

#initialize(**options) ⇒ TestStrategy

Returns a new instance of TestStrategy.



6
7
8
9
# File 'lib/flipflop/strategies/test_strategy.rb', line 6

def initialize(**options)
  @features = {}
  super(**options)
end

Instance Method Details

#clear!(feature) ⇒ Object



27
28
29
30
31
# File 'lib/flipflop/strategies/test_strategy.rb', line 27

def clear!(feature)
  @@lock.synchronize do
    @features.delete(feature)
  end
end

#enabled?(feature) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
18
19
# File 'lib/flipflop/strategies/test_strategy.rb', line 15

def enabled?(feature)
  @@lock.synchronize do
    @features[feature]
  end
end

#reset!Object



33
34
35
36
37
# File 'lib/flipflop/strategies/test_strategy.rb', line 33

def reset!
  @@lock.synchronize do
    @features.clear
  end
end

#switch!(feature, enabled) ⇒ Object



21
22
23
24
25
# File 'lib/flipflop/strategies/test_strategy.rb', line 21

def switch!(feature, enabled)
  @@lock.synchronize do
    @features[feature] = enabled
  end
end

#switchable?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/flipflop/strategies/test_strategy.rb', line 11

def switchable?
  true
end