Module: FlipperTrail
- Defined in:
- lib/flipper_trail.rb,
lib/flipper_trail/actor.rb,
lib/flipper_trail/entry.rb,
lib/flipper_trail/adapter.rb,
lib/flipper_trail/current.rb,
lib/flipper_trail/railtie.rb,
lib/flipper_trail/version.rb,
lib/flipper_trail/recorder.rb,
lib/flipper_trail/middleware.rb,
lib/flipper_trail/configuration.rb,
lib/flipper_trail/storage/mongoid.rb,
lib/flipper_trail/storage/active_record.rb,
lib/flipper_trail/generators/flipper_trail/install_generator.rb
Overview
Records an append-only audit trail of Flipper feature-flag changes — who changed what, when, and the before/after state — via an adapter decorator. FlipperTrail.configure it once, then query it with FlipperTrail.history.
Defined Under Namespace
Modules: Generators, Storage Classes: Actor, Adapter, Configuration, Current, Entry, Middleware, Railtie, Recorder
Constant Summary collapse
- VERSION =
'0.1.0'
Class Method Summary collapse
-
.configuration ⇒ Configuration
The memoized global configuration.
-
.configure {|config| ... } ⇒ void
Configures the gem by yielding the global Configuration.
-
.current_actor ⇒ Actor?
The actor the recorder would attribute a change to right now.
-
.history(**filters) ⇒ Array<Entry>
Queries the audit trail through the configured storage backend.
-
.recorder ⇒ Recorder
The memoized global recorder that builds and persists audit entries.
-
.reset! ⇒ void
Resets the memoized configuration, recorder, and per-request actor.
-
.wrap(adapter, recorder: nil) ⇒ FlipperTrail::Adapter
Wrap a Flipper adapter so every write through it is audited.
Class Method Details
.configuration ⇒ Configuration
The memoized global configuration.
20 21 22 |
# File 'lib/flipper_trail.rb', line 20 def configuration @configuration ||= Configuration.new end |
.configure {|config| ... } ⇒ void
This method returns an undefined value.
Configures the gem by yielding the global Configuration.
54 55 56 |
# File 'lib/flipper_trail.rb', line 54 def configure yield configuration end |
.current_actor ⇒ Actor?
The actor the recorder would attribute a change to right now.
83 84 85 |
# File 'lib/flipper_trail.rb', line 83 def current_actor recorder.current_actor end |
.history(**filters) ⇒ Array<Entry>
Queries the audit trail through the configured storage backend.
70 71 72 73 74 75 76 77 78 |
# File 'lib/flipper_trail.rb', line 70 def history(**filters) configuration.storage_backend.query( feature: filters[:feature], actor_id: filters[:actor_id], since: filters[:since], until_time: filters[:until], limit: filters[:limit] || 100 ) end |
.recorder ⇒ Recorder
The memoized global recorder that builds and persists audit entries.
27 28 29 |
# File 'lib/flipper_trail.rb', line 27 def recorder @recorder ||= Recorder.new end |
.reset! ⇒ void
This method returns an undefined value.
Resets the memoized configuration, recorder, and per-request actor.
90 91 92 93 94 |
# File 'lib/flipper_trail.rb', line 90 def reset! @configuration = nil @recorder = nil Current.reset if defined?(Current) end |
.wrap(adapter, recorder: nil) ⇒ FlipperTrail::Adapter
Wrap a Flipper adapter so every write through it is audited.
Shorthand for FlipperTrail::Adapter.new(adapter); pass the result to Flipper’s config.adapter.
40 41 42 |
# File 'lib/flipper_trail.rb', line 40 def wrap(adapter, recorder: nil) Adapter.new(adapter, recorder: recorder) end |