class EventStore::Client
Attributes
aggregate[R]
Public Class Methods
count()
click to toggle source
# File lib/event_store/client.rb, line 17 def self.count Aggregate.count end
ids(offset, limit)
click to toggle source
# File lib/event_store/client.rb, line 21 def self.ids(offset, limit) Aggregate.ids(offset, limit) end
new(aggregate_id, aggregate_type = EventStore.table_name, checkpoint_events = [])
click to toggle source
# File lib/event_store/client.rb, line 25 def initialize(aggregate_id, aggregate_type = EventStore.table_name, checkpoint_events = []) checkpoint_events = [checkpoint_events].flatten @aggregate = Aggregate.new(aggregate_id, aggregate_type, checkpoint_events) end
Public Instance Methods
append(event_data, logger=default_logger) { |event_data| ... }
click to toggle source
# File lib/event_store/client.rb, line 34 def append(event_data, logger=default_logger) logger.debug("Start Appending #{event_data} to #{id}") aggregate.append(event_data, logger) logger.debug("Done Appending #{event_data} to #{id}") yield(event_data) if block_given? nil end
destroy!()
click to toggle source
# File lib/event_store/client.rb, line 78 def destroy! aggregate.delete_events! aggregate.delete_snapshot! end
event_stream()
click to toggle source
# File lib/event_store/client.rb, line 46 def event_stream translate_events(raw_event_stream) end
event_stream_between(start_time, end_time, fully_qualified_names = [])
click to toggle source
# File lib/event_store/client.rb, line 58 def event_stream_between(start_time, end_time, fully_qualified_names = []) translate_events(aggregate.event_stream_between(start_time, end_time, fully_qualified_names)) end
event_stream_from(event_id, max=nil)
click to toggle source
# File lib/event_store/client.rb, line 50 def event_stream_from(event_id, max=nil) translate_events(aggregate.events_from(event_id, max)) end
exists?()
click to toggle source
# File lib/event_store/client.rb, line 30 def exists? aggregate.snapshot_exists? end
last_event_before(start_time, fully_qualified_names = [])
click to toggle source
# File lib/event_store/client.rb, line 54 def last_event_before(start_time, fully_qualified_names = []) translate_events(aggregate.last_event_before(start_time, fully_qualified_names)) end
peek()
click to toggle source
# File lib/event_store/client.rb, line 62 def peek aggregate.last_event end
raw_event_stream()
click to toggle source
# File lib/event_store/client.rb, line 70 def raw_event_stream aggregate.event_stream end
raw_event_stream_from(event_id, max=nil)
click to toggle source
# File lib/event_store/client.rb, line 74 def raw_event_stream_from(event_id, max=nil) aggregate.events_from(event_id, max) end
raw_snapshot()
click to toggle source
# File lib/event_store/client.rb, line 66 def raw_snapshot aggregate.snapshot end
rebuild_snapshot!()
click to toggle source
# File lib/event_store/client.rb, line 83 def rebuild_snapshot! aggregate.delete_snapshot! aggregate.rebuild_snapshot! end
snapshot()
click to toggle source
# File lib/event_store/client.rb, line 42 def snapshot raw_snapshot end
Private Instance Methods
default_logger()
click to toggle source
# File lib/event_store/client.rb, line 92 def default_logger Logger.new("/dev/null") end
translate_event(event_hash)
click to toggle source
# File lib/event_store/client.rb, line 100 def translate_event(event_hash) return if event_hash.empty? occurred_at = TimeHacker.translate_occurred_at_from_local_to_gmt(event_hash[:occurred_at]) SerializedEvent.new event_hash[:fully_qualified_name], event_hash[:serialized_event], event_hash[:id], occurred_at end
translate_events(event_hashs)
click to toggle source
# File lib/event_store/client.rb, line 96 def translate_events(event_hashs) event_hashs.map { |eh| translate_event(eh) } end