class SnapshotAggregateRoot::DefaultApplyStrategy
Attributes
strict[R]
Public Class Methods
new(strict: true)
click to toggle source
# File lib/snapshot_aggregate_root/default_apply_strategy.rb, line 5 def initialize(strict: true) @strict = strict end
Public Instance Methods
call(aggregate, event)
click to toggle source
# File lib/snapshot_aggregate_root/default_apply_strategy.rb, line 9 def call(aggregate, event) name = handler_name(event) if aggregate.respond_to?(name, true) aggregate.method(name).call(event) else raise MissingHandler.new("Missing handler method #{name} on aggregate #{aggregate.class}") if strict end end
Private Instance Methods
handler_name(event)
click to toggle source
# File lib/snapshot_aggregate_root/default_apply_strategy.rb, line 21 def handler_name(event) "apply_#{event.class.name.demodulize.underscore}" end