Class: TCB::CorrelationQuery
- Inherits:
-
Object
- Object
- TCB::CorrelationQuery
- Defined in:
- lib/tcb/correlation_query.rb
Instance Method Summary collapse
- #between(from, to) ⇒ Object
-
#initialize(store:, correlation_id:, domains:, occurred_after: nil, occurred_before: nil) ⇒ CorrelationQuery
constructor
A new instance of CorrelationQuery.
- #occurred_after(time) ⇒ Object
- #occurred_before(time) ⇒ Object
- #to_a ⇒ Object
Constructor Details
#initialize(store:, correlation_id:, domains:, occurred_after: nil, occurred_before: nil) ⇒ CorrelationQuery
Returns a new instance of CorrelationQuery.
5 6 7 8 9 10 11 |
# File 'lib/tcb/correlation_query.rb', line 5 def initialize(store:, correlation_id:, domains:, occurred_after: nil, occurred_before: nil) @store = store @correlation_id = correlation_id @domains = domains @occurred_after = occurred_after @occurred_before = occurred_before end |
Instance Method Details
#between(from, to) ⇒ Object
21 22 23 |
# File 'lib/tcb/correlation_query.rb', line 21 def between(from, to) occurred_after(from).occurred_before(to) end |
#occurred_after(time) ⇒ Object
13 14 15 |
# File 'lib/tcb/correlation_query.rb', line 13 def occurred_after(time) self.class.new(store: @store, correlation_id: @correlation_id, domains: @domains, occurred_after: time, occurred_before: @occurred_before) end |
#occurred_before(time) ⇒ Object
17 18 19 |
# File 'lib/tcb/correlation_query.rb', line 17 def occurred_before(time) self.class.new(store: @store, correlation_id: @correlation_id, domains: @domains, occurred_after: @occurred_after, occurred_before: time) end |
#to_a ⇒ Object
25 26 27 28 29 30 |
# File 'lib/tcb/correlation_query.rb', line 25 def to_a @domains.flat_map do |domain| context = DomainContext.from_module(domain).to_s @store.read_by_correlation(@correlation_id, context: context, occurred_after: @occurred_after, occurred_before: @occurred_before) end.sort_by(&:occurred_at) end |