Class: FlipperTrail::Recorder
- Inherits:
-
Object
- Object
- FlipperTrail::Recorder
- Defined in:
- lib/flipper_trail/recorder.rb
Overview
Builds an Entry from a flag change and persists it through the configured storage backend. No-op changes (‘before == after`) and ignored features are dropped.
Instance Method Summary collapse
-
#current_actor ⇒ Actor?
Resolves the actor to attribute a change to, trying the per-request Current actor, then the configured ‘actor_resolver`, then the system actor.
-
#record(feature_name:, operation:, gate_name:, before:, after:) ⇒ Entry?
Records a single flag change as an audit entry.
Instance Method Details
#current_actor ⇒ Actor?
Resolves the actor to attribute a change to, trying the per-request Current actor, then the configured ‘actor_resolver`, then the system actor.
43 44 45 46 |
# File 'lib/flipper_trail/recorder.rb', line 43 def current_actor raw = Current.actor || config.actor_resolver&.call || config.system_actor Actor.wrap(raw) end |
#record(feature_name:, operation:, gate_name:, before:, after:) ⇒ Entry?
Records a single flag change as an audit entry.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/flipper_trail/recorder.rb', line 21 def record(feature_name:, operation:, gate_name:, before:, after:) feature_name = feature_name.to_s return if config.ignored_features.map(&:to_s).include?(feature_name) return if before == after entry = Entry.new( feature_name: feature_name, operation: operation, gate_name: gate_name&.to_s, before: before, after: after, actor: current_actor, created_at: Time.now ).freeze persist(entry) entry end |