lib/cyberarm_engine/ui/event.rb in cyberarm_engine-0.14.0 vs lib/cyberarm_engine/ui/event.rb in cyberarm_engine-0.15.0

- old
+ new

@@ -13,35 +13,35 @@ def publish(event, *args) raise ArgumentError, "#{self.class} does not handle #{event.inspect}" unless @event_handler.include?(event) return unless enabled? - if respond_to?(event) - return :handled if send(event, self, *args) == :handled - end + return :handled if respond_to?(event) && (send(event, self, *args) == :handled) @event_handler[event].reverse_each do |handler| return :handled if handler.call(self, *args) == :handled end parent.publish(event, *args) if parent - return nil + nil end def event(event) - @event_handler ||= Hash.new + @event_handler ||= {} @event_handler[event] ||= [] end end class Subscription attr_reader :publisher, :event, :handler def initialize(publisher, event, handler) - @publisher, @event, @handler = publisher, event, handler + @publisher = publisher + @event = event + @handler = handler end def unsubscribe @publisher.unsubscribe(self) end end -end \ No newline at end of file +end