Class: Dolphin::FlipperStore

Inherits:
Object
  • Object
show all
Defined in:
lib/dolphin/flipper_store.rb

Defined Under Namespace

Classes: DSL

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeFlipperStore

Returns a new instance of FlipperStore


17
18
19
# File 'lib/dolphin/flipper_store.rb', line 17

def initialize
  @flipper_store = FlipperStore.default_flippers
end

Class Method Details

.default_flippersObject


33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/dolphin/flipper_store.rb', line 33

def self.default_flippers
  @default_flippers ||= {
    'enabled'     => lambda { |*args| true },
    'disabled'    => lambda { |*args| false },
    'chance_1pc'  => lambda { |*args| rand < 0.01 },
    'chance_2pc'  => lambda { |*args| rand < 0.02 },
    'chance_5pc'  => lambda { |*args| rand < 0.05 },
    'chance_10pc' => lambda { |*args| rand < 0.1 },
    'chance_20pc' => lambda { |*args| rand < 0.2 },
    'chance_50pc' => lambda { |*args| rand < 0.5 }
  }
end

Instance Method Details

#[](name) ⇒ Object


25
26
27
# File 'lib/dolphin/flipper_store.rb', line 25

def [](name)
  @flipper_store[name.to_s]
end

#set_flipper(name, block) ⇒ Object


21
22
23
# File 'lib/dolphin/flipper_store.rb', line 21

def set_flipper(name, block)
  @flipper_store[name.to_s] = block
end

#to_hashObject


29
30
31
# File 'lib/dolphin/flipper_store.rb', line 29

def to_hash
  @flipper_store
end