File tree 1 file changed +6
-3
lines changed
1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ module OnDSL
14
14
15
15
def on ( *event_klasses , &block )
16
16
event_klasses . each do |event_klass |
17
- name = event_klass . to_s
17
+ name = event_type_for ( event_klass )
18
18
raise ( ArgumentError , "Anonymous class is missing name" ) if name . start_with? ANONYMOUS_CLASS
19
19
20
20
handler_name = "on_#{ name } "
@@ -80,11 +80,14 @@ def self.with_strategy(strategy)
80
80
with ( strategy : strategy )
81
81
end
82
82
83
- def self . with ( strategy : -> { DefaultApplyStrategy . new } )
83
+ def self . with ( strategy : -> { DefaultApplyStrategy . new } , event_type_resolver : -> ( value ) { value . to_s } )
84
84
Module . new do
85
- def self . included ( host_class )
85
+ define_singleton_method : included do | host_class |
86
86
host_class . extend Constructor
87
87
host_class . include AggregateMethods
88
+ host_class . define_singleton_method :event_type_for do |value |
89
+ event_type_resolver . call ( value )
90
+ end
88
91
end
89
92
90
93
define_method :apply_strategy do
You can’t perform that action at this time.
0 commit comments