Sha256: b40b90391d3639b2643ade785da19384684b81456d78b2f6ab4b998ebc99077c

Contents?: true

Size: 364 Bytes

Versions: 9

Compression:

Stored size: 364 Bytes

Contents

module Reactor::Subscribable
  extend ActiveSupport::Concern

  module ClassMethods
    def on_event(event, method = nil, options = {}, &block)
      callback = {method: (method || block), options: {delay: 0}.merge(options)}
      callback.merge!(source: self) if method.is_a? Symbol
      (Reactor::SUBSCRIBERS[event.to_s] ||= []).push(callback)
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
reactor-0.5.1 lib/reactor/models/concerns/subscribable.rb
reactor-0.5.0 lib/reactor/models/concerns/subscribable.rb
reactor-0.4.7 lib/reactor/models/concerns/subscribable.rb
reactor-0.4.6 lib/reactor/models/concerns/subscribable.rb
reactor-0.4.5 lib/reactor/models/concerns/subscribable.rb
reactor-0.4.4 lib/reactor/models/concerns/subscribable.rb
reactor-0.4.3 lib/reactor/models/concerns/subscribable.rb
reactor-0.4.2 lib/reactor/models/concerns/subscribable.rb
reactor-0.4.0 lib/reactor/models/concerns/subscribable.rb