Sha256: 28d71ccb3b6239af4ad20ead7c048762fe99cf345cf8d4bc93dbbb0c0b25ad0c

Contents?: true

Size: 487 Bytes

Versions: 24

Compression:

Stored size: 487 Bytes

Contents

class Reactor::Subscriber < ActiveRecord::Base
  attr_accessor :event

  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

  class << self
    def on_fire(&block)
      if block
        @fire_block = block
      end
      @fire_block
    end

    def fire(subscriber_id, data)
      Reactor::Subscriber.find(subscriber_id).fire data
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
reactor-0.13.0 lib/reactor/models/subscriber.rb
reactor-0.12.2 lib/reactor/models/subscriber.rb
reactor-0.12.1 lib/reactor/models/subscriber.rb
reactor-0.11.4 lib/reactor/models/subscriber.rb
reactor-0.11.2 lib/reactor/models/subscriber.rb
reactor-0.11.1 lib/reactor/models/subscriber.rb
reactor-0.11.0 lib/reactor/models/subscriber.rb
reactor-0.10.1 lib/reactor/models/subscriber.rb
reactor-0.10.0 lib/reactor/models/subscriber.rb
reactor-0.9.9 lib/reactor/models/subscriber.rb
reactor-0.9.8 lib/reactor/models/subscriber.rb
reactor-0.9.7 lib/reactor/models/subscriber.rb
reactor-0.9.6 lib/reactor/models/subscriber.rb
reactor-0.9.5 lib/reactor/models/subscriber.rb
reactor-0.9.4 lib/reactor/models/subscriber.rb
reactor-0.9.2 lib/reactor/models/subscriber.rb
reactor-0.9.1 lib/reactor/models/subscriber.rb
reactor-0.9.0 lib/reactor/models/subscriber.rb
reactor-0.8.3 lib/reactor/models/subscriber.rb
reactor-0.8.2 lib/reactor/models/subscriber.rb