Sha256: 7784a41e3d54338dba318e216821996a1cfe1e443eae36e126a653ee848a395e

Contents?: true

Size: 751 Bytes

Versions: 1

Compression:

Stored size: 751 Bytes

Contents

require 'celluloid/autostart'
require 'wisper'
require "wisper/async/version"
require "wisper/async/listener"

module Wisper
  class ObjectRegistration
    attr_reader :async

    alias_method :old_initialize, :initialize

    def initialize(listener, options)
      @async = options.delete(:async) { false }
      old_initialize(listener, options)
    end

    def broadcast(event, publisher, *args)
      method_to_call = map_event_to_method(event)
      if should_broadcast?(event) && listener.respond_to?(method_to_call)
        unless async
          listener.public_send(method_to_call, *args)
        else
          Async::Listener.new(listener, method_to_call).async.public_send(method_to_call, *args)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wisper-async-0.1.0 lib/wisper/async.rb