Class: RubyEventStore::MCP::ReadEvents

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_event_store/mcp/read_events.rb

Class Method Summary collapse

Class Method Details

.of(specification, type: nil, after: nil, before: nil, from: nil, limit: nil) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/ruby_event_store/mcp/read_events.rb', line 6

def self.of(specification, type: nil, after: nil, before: nil, from: nil, limit: nil)
  specification = specification.of_type(resolve_type(type))    if type
  specification = specification.newer_than(Time.parse(after))  if after
  specification = specification.older_than(Time.parse(before)) if before
  specification = specification.from(from)                     if from
  limit ? specification.limit(limit.to_i).to_a : specification.to_a
end

.resolve_type(name) ⇒ Object



14
15
16
17
18
# File 'lib/ruby_event_store/mcp/read_events.rb', line 14

def self.resolve_type(name)
  Object.const_get(name)
rescue NameError
  raise "Unknown event type: #{name}"
end