Class: FlipperTrail::Adapter
- Inherits:
-
Object
- Object
- FlipperTrail::Adapter
- Includes:
- Flipper::Adapter
- Defined in:
- lib/flipper_trail/adapter.rb
Overview
A Flipper adapter decorator that captures the before/after state of every write (add, remove, clear, enable, disable) and records it as an audit entry. Reads and bulk operations pass straight through unaudited.
Instance Attribute Summary collapse
-
#adapter ⇒ Object
readonly
Public reader so Flipper::Adapter#adapter_stack recurses into us (matches Flipper’s own Wrapper/Memoizable).
Instance Method Summary collapse
-
#add(feature) ⇒ Object
— writes: capture before/after —.
- #clear(feature) ⇒ Object
- #disable(feature, gate, thing) ⇒ Object
- #enable(feature, gate, thing) ⇒ Object
- #export(*args, **kwargs) ⇒ Object
-
#features ⇒ Object
— reads / bulk ops: pass straight through (not audited) — NOTE: get_all/export take kwargs in Flipper 1.x (Synchronizer/Memoizable/Cache call get_all(**kwargs)); the override MUST keep that arity or it raises ArgumentError on import/sync/cloud paths.
- #get(feature) ⇒ Object
- #get_all(**kwargs) ⇒ Object
- #get_multi(features) ⇒ Object
- #import(source) ⇒ Object
-
#initialize(adapter, recorder: nil) ⇒ Adapter
constructor
A new instance of Adapter.
- #name ⇒ Object
- #read_only? ⇒ Boolean
- #remove(feature) ⇒ Object
Constructor Details
#initialize(adapter, recorder: nil) ⇒ Adapter
Returns a new instance of Adapter.
21 22 23 24 25 |
# File 'lib/flipper_trail/adapter.rb', line 21 def initialize(adapter, recorder: nil) @adapter = adapter @recorder = recorder FlipperTrail.configuration.infer_storage_from(adapter) end |
Instance Attribute Details
#adapter ⇒ Object (readonly)
Public reader so Flipper::Adapter#adapter_stack recurses into us (matches Flipper’s own Wrapper/Memoizable).
28 29 30 |
# File 'lib/flipper_trail/adapter.rb', line 28 def adapter @adapter end |
Instance Method Details
#add(feature) ⇒ Object
— writes: capture before/after —
46 47 48 49 50 51 52 |
# File 'lib/flipper_trail/adapter.rb', line 46 def add(feature) existed = @adapter.features.include?(feature.key) before = existed ? snapshot(feature) : nil result = @adapter.add(feature) record(feature, :add, nil, before, snapshot(feature)) result end |
#clear(feature) ⇒ Object
61 62 63 64 65 66 |
# File 'lib/flipper_trail/adapter.rb', line 61 def clear(feature) before = snapshot(feature) result = @adapter.clear(feature) record(feature, :clear, nil, before, snapshot(feature)) result end |
#disable(feature, gate, thing) ⇒ Object
75 76 77 78 79 80 |
# File 'lib/flipper_trail/adapter.rb', line 75 def disable(feature, gate, thing) before = snapshot(feature) result = @adapter.disable(feature, gate, thing) record(feature, :disable, gate.name, before, snapshot(feature)) result end |
#enable(feature, gate, thing) ⇒ Object
68 69 70 71 72 73 |
# File 'lib/flipper_trail/adapter.rb', line 68 def enable(feature, gate, thing) before = snapshot(feature) result = @adapter.enable(feature, gate, thing) record(feature, :enable, gate.name, before, snapshot(feature)) result end |
#export(*args, **kwargs) ⇒ Object
43 |
# File 'lib/flipper_trail/adapter.rb', line 43 def export(*args, **kwargs) = @adapter.export(*args, **kwargs) |
#features ⇒ Object
— reads / bulk ops: pass straight through (not audited) — NOTE: get_all/export take kwargs in Flipper 1.x (Synchronizer/Memoizable/Cache call get_all(**kwargs)); the override MUST keep that arity or it raises ArgumentError on import/sync/cloud paths.
37 |
# File 'lib/flipper_trail/adapter.rb', line 37 def features = @adapter.features |
#get(feature) ⇒ Object
38 |
# File 'lib/flipper_trail/adapter.rb', line 38 def get(feature) = @adapter.get(feature) |
#get_all(**kwargs) ⇒ Object
40 |
# File 'lib/flipper_trail/adapter.rb', line 40 def get_all(**kwargs) = @adapter.get_all(**kwargs) |
#get_multi(features) ⇒ Object
39 |
# File 'lib/flipper_trail/adapter.rb', line 39 def get_multi(features) = @adapter.get_multi(features) |
#import(source) ⇒ Object
42 |
# File 'lib/flipper_trail/adapter.rb', line 42 def import(source) = @adapter.import(source) |
#name ⇒ Object
30 31 32 |
# File 'lib/flipper_trail/adapter.rb', line 30 def name @adapter.name end |
#read_only? ⇒ Boolean
41 |
# File 'lib/flipper_trail/adapter.rb', line 41 def read_only? = @adapter.read_only? |
#remove(feature) ⇒ Object
54 55 56 57 58 59 |
# File 'lib/flipper_trail/adapter.rb', line 54 def remove(feature) before = snapshot(feature) result = @adapter.remove(feature) record(feature, :remove, nil, before, nil) result end |