class SandthornSequelProjection::Projection
Attributes
event_handlers[RW]
event_store_name[R]
db_connection[R]
event_handlers[R]
tracker[R]
Public Class Methods
define_event_handlers() { |event_handlers| ... }
click to toggle source
# File lib/sandthorn_sequel_projection/projection.rb, line 53 def define_event_handlers @event_handlers ||= EventHandlerCollection.new yield(@event_handlers) end
event_store(event_store = nil)
click to toggle source
# File lib/sandthorn_sequel_projection/projection.rb, line 39 def event_store(event_store = nil) if event_store @event_store_name = event_store else find_event_store end end
find_event_store()
click to toggle source
# File lib/sandthorn_sequel_projection/projection.rb, line 47 def find_event_store SandthornSequelProjection.find_event_store(@event_store_name) end
identifier()
click to toggle source
# File lib/sandthorn_sequel_projection/projection.rb, line 58 def identifier self.name.gsub(/::/, '_'). gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2'). gsub(/([a-z\d])([A-Z])/,'\1_\2'). tr("-", "_"). downcase end
new(db_connection = nil)
click to toggle source
# File lib/sandthorn_sequel_projection/projection.rb, line 13 def initialize(db_connection = nil) @db_connection = db_connection || SandthornSequelProjection.configuration.db_connection @tracker = ProcessedEventsTracker.new( identifier: identifier, db_connection: @db_connection, event_store: event_store) @event_handlers = self.class.event_handlers end
Public Instance Methods
klass()
click to toggle source
# File lib/sandthorn_sequel_projection/projection.rb, line 28 def klass self.class end
migrator()
click to toggle source
# File lib/sandthorn_sequel_projection/projection.rb, line 32 def migrator SimpleMigrator.migrator(db_connection) end
update!()
click to toggle source
# File lib/sandthorn_sequel_projection/projection.rb, line 22 def update! tracker.process_events do |batch| event_handlers.handle(self, batch) end end