Class: Flipper::Adapters::Failsafe

Inherits:
Object
  • Object
show all
Includes:
Flipper::Adapter
Defined in:
lib/flipper/adapters/failsafe.rb

Instance Method Summary collapse

Methods included from Flipper::Adapter

#default_config, #export, #import, included, #name

Constructor Details

#initialize(adapter, options = {}) ⇒ Failsafe

Public: Build a new Failsafe instance.

adapter - Flipper adapter to guard. options - Hash of options:

:errors - Array of exception types for which to fail safe


12
13
14
15
# File 'lib/flipper/adapters/failsafe.rb', line 12

def initialize(adapter, options = {})
  @adapter = adapter
  @errors = options.fetch(:errors, [StandardError])
end

Instance Method Details

#add(feature) ⇒ Object



23
24
25
26
27
# File 'lib/flipper/adapters/failsafe.rb', line 23

def add(feature)
  @adapter.add(feature)
rescue *@errors
  false
end

#clear(feature) ⇒ Object



35
36
37
38
39
# File 'lib/flipper/adapters/failsafe.rb', line 35

def clear(feature)
  @adapter.clear(feature)
rescue *@errors
  false
end

#disable(feature, gate, thing) ⇒ Object



65
66
67
68
69
# File 'lib/flipper/adapters/failsafe.rb', line 65

def disable(feature, gate, thing)
  @adapter.disable(feature, gate, thing)
rescue *@errors
  false
end

#enable(feature, gate, thing) ⇒ Object



59
60
61
62
63
# File 'lib/flipper/adapters/failsafe.rb', line 59

def enable(feature, gate, thing)
  @adapter.enable(feature, gate, thing)
rescue *@errors
  false
end

#featuresObject



17
18
19
20
21
# File 'lib/flipper/adapters/failsafe.rb', line 17

def features
  @adapter.features
rescue *@errors
  Set.new
end

#get(feature) ⇒ Object



41
42
43
44
45
# File 'lib/flipper/adapters/failsafe.rb', line 41

def get(feature)
  @adapter.get(feature)
rescue *@errors
  {}
end

#get_allObject



53
54
55
56
57
# File 'lib/flipper/adapters/failsafe.rb', line 53

def get_all
  @adapter.get_all
rescue *@errors
  {}
end

#get_multi(features) ⇒ Object



47
48
49
50
51
# File 'lib/flipper/adapters/failsafe.rb', line 47

def get_multi(features)
  @adapter.get_multi(features)
rescue *@errors
  {}
end

#remove(feature) ⇒ Object



29
30
31
32
33
# File 'lib/flipper/adapters/failsafe.rb', line 29

def remove(feature)
  @adapter.remove(feature)
rescue *@errors
  false
end