Skip to content

Commit a973141

Browse files
lukaszreszkemostlyobvious
authored andcommitted
Remove ANONYMOUS_CLASS guard
Not a practical example. Hard to imagine real life use case for passing anonymous class. Co-authored-by: Paweł Pacana <[email protected]>
1 parent 502603c commit a973141

File tree

3 files changed

+0
-16
lines changed

3 files changed

+0
-16
lines changed

aggregate_root/lib/aggregate_root.rb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,9 @@
99

1010
module AggregateRoot
1111
module OnDSL
12-
ANONYMOUS_CLASS = "#<Class:".freeze
13-
1412
def on(*event_klasses, &block)
1513
event_klasses.each do |event_klass|
1614
name = event_klass.to_s
17-
raise(ArgumentError, "Anonymous class is missing name") if name.start_with? ANONYMOUS_CLASS
1815

1916
handler_name = "on_#{name}"
2017
define_method(handler_name, &block)

aggregate_root/spec/aggregate_root_spec.rb

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -256,16 +256,6 @@ def custom_expired(_event)
256256
order.apply(Orders::Events::OrderExpired.new)
257257
expect(order.status).to eq(%i[base_expired inherited_expired])
258258
end
259-
260-
it "does not support anonymous events" do
261-
expect do
262-
Class.new do
263-
include AggregateRoot
264-
265-
on(Class.new) { |_ev| }
266-
end
267-
end.to raise_error(ArgumentError, "Anonymous class is missing name")
268-
end
269259
end
270260

271261
describe "#initialize" do

ruby_event_store/lib/ruby_event_store/projection.rb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ module RubyEventStore
44
class Projection
55
private_class_method :new
66

7-
ANONYMOUS_CLASS = "#<Class:".freeze
8-
97
def initialize(initial_state = nil)
108
@handlers = {}
119
@init = -> { initial_state }
@@ -20,7 +18,6 @@ def on(*event_klasses, &block)
2018

2119
event_klasses.each do |event_klass|
2220
name = event_klass.to_s
23-
raise(ArgumentError, 'Anonymous class is missing name') if name.start_with? ANONYMOUS_CLASS
2421

2522
@handlers[name] = ->(state, event) { block.call(state, event) }
2623
end

0 commit comments

Comments
 (0)