lib/emittance/dispatchers/synchronous.rb in emittance-0.0.4 vs lib/emittance/dispatchers/synchronous.rb in emittance-0.0.5

- old
+ new

@@ -23,11 +23,11 @@ end def register(identifier, &callback) event_klass = find_event_klass identifier registrations[event_klass] ||= empty_registration - registrations_for(event_klass) << Emittance::Registration.new(event_klass, &callback) + registrations_for(event_klass) << Registration.new(event_klass, &callback) callback end def register_method_call(identifier, object, method_name) @@ -57,9 +57,23 @@ Emittance::EventLookup.find_event_klass(event) end def lambda_for_method_call(object, method_name) ->(event) { object.send method_name, event } + end + end + + # @private + class Registration + attr_reader :event_klass + + def initialize(event_klass, &callback) + @event_klass = event_klass + @callback = callback + end + + def call(event) + @callback.call event end end end end end