Class: Conjur::Audit::Follower
- Inherits:
-
Object
- Object
- Conjur::Audit::Follower
- Defined in:
- lib/conjur/audit/follower.rb
Instance Method Summary collapse
-
#filter(&filter) ⇒ Object
Filter events received so that only events for which :block: returns truthy are passed to the block given to :#follow:.
-
#follow(&block) ⇒ Object
Follow audit events, yielding non-empty arrays of new events to :block: as they are fetched.
-
#initialize(&block) ⇒ Follower
constructor
Initialize a follower that will fetch more records by calling :block: with options to merge into the options passed to the audit method (eg, limit, offset).
Constructor Details
#initialize(&block) ⇒ Follower
Initialize a follower that will fetch more records by calling :block: with options to merge into the options passed to the audit method (eg, limit, offset)
7 8 9 |
# File 'lib/conjur/audit/follower.rb', line 7 def initialize &block @fetch = block end |
Instance Method Details
#filter(&filter) ⇒ Object
Filter events received so that only events for which :block: returns truthy are passed to the block given to :#follow:.
14 15 16 |
# File 'lib/conjur/audit/follower.rb', line 14 def filter &filter @filter = filter end |
#follow(&block) ⇒ Object
Follow audit events, yielding non-empty arrays of new events to :block: as they are fetched.
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/conjur/audit/follower.rb', line 21 def follow &block @last_event_id = nil loop do new_events = fetch_new_events new_events.select!(&@filter) if @filter if new_events.empty? sleep 1 else block.call new_events end end end |