Skip to content

Commit 4184a99

Browse files
lukaszreszkemostlyobvious
authored andcommitted
Allow projection from one stream only
1 parent 80fad98 commit 4184a99

File tree

2 files changed

+2
-18
lines changed

2 files changed

+2
-18
lines changed

ruby_event_store/lib/ruby_event_store/projection.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,10 @@ def on(*event_klasses, &block)
2121
self
2222
end
2323

24-
def call(*scopes)
24+
def call(scope)
2525
return initial_state if handled_events.empty?
2626

27-
scopes.reduce(initial_state) do |state, scope|
28-
scope.of_types(handled_events).reduce(state, &method(:transition))
29-
end
27+
scope.of_types(handled_events).reduce(initial_state, &method(:transition))
3028
end
3129

3230
private

ruby_event_store/spec/projection_spec.rb

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,6 @@ module RubyEventStore
3232
expect(account_balance).to eq(25)
3333
end
3434

35-
specify "reduce events from many streams" do
36-
event_store.append(MoneyDeposited.new(data: { amount: 10 }), stream_name: "Customer$1")
37-
event_store.append(MoneyDeposited.new(data: { amount: 20 }), stream_name: "Customer$2")
38-
event_store.append(MoneyWithdrawn.new(data: { amount: 5 }), stream_name: "Customer$3")
39-
40-
account_balance =
41-
Projection
42-
.new(0)
43-
.on(MoneyDeposited) { |state, event| state += event.data[:amount] }
44-
.on(MoneyWithdrawn) { |state, event| state -= event.data[:amount] }
45-
.call(event_store.read.stream("Customer$1"), event_store.read.stream("Customer$3"))
46-
expect(account_balance).to eq(5)
47-
end
48-
4935
specify "take events from all streams" do
5036
event_store.append(MoneyDeposited.new(data: { amount: 1 }), stream_name: "Customer$1")
5137
event_store.append(MoneyDeposited.new(data: { amount: 1 }), stream_name: "Customer$2")

0 commit comments

Comments
 (0)