13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/sourced/evolve.rb', line 13
def evolve(*args)
state = self
case args
in [events]
events.each do |event|
method_name = Sourced.message_method_name(Evolve::PREFIX, event.class.to_s)
if respond_to?(method_name)
before_evolve(event)
send(method_name, event)
end
end
in [obj, events]
state = obj
events.each do |event|
method_name = Sourced.message_method_name(Evolve::PREFIX, event.class.to_s)
if respond_to?(method_name)
before_evolve(state, event)
send(method_name, state, event)
end
end
end
state
end
|