lib/reactor/models/subscriber.rb in reactor-0.13.0 vs lib/reactor/models/subscriber.rb in reactor-0.14.0

- old
+ new

@@ -1,26 +1,28 @@ -class Reactor::Subscriber < ActiveRecord::Base - attr_accessor :event +module Reactor + class Subscriber < ActiveRecord::Base + attr_accessor :event - def event_name=(event) - write_attribute :event_name, event.to_s - end + def event_name=(event) + write_attribute :event_name, event.to_s + end - def fire(data) - self.event = Reactor::Event.new(data) - instance_exec &self.class.on_fire - self - end + def fire(data) + self.event = Reactor::Event.new(data) + instance_exec &self.class.on_fire + self + end - class << self - def on_fire(&block) - if block - @fire_block = block + class << self + def on_fire(&block) + if block + @fire_block = block + end + @fire_block end - @fire_block - end - def fire(subscriber_id, data) - Reactor::Subscriber.find(subscriber_id).fire data + def fire(subscriber_id, data) + Reactor::Subscriber.find(subscriber_id).fire data.with_indifferent_access + end end end -end \ No newline at end of file +end