Sha256: 276ceedf7025f4695948bdbefca0c386c9776d2b50af628485ea8f32f423decd

Contents?: true

Size: 680 Bytes

Versions: 1

Compression:

Stored size: 680 Bytes

Contents

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

module Wisper
  class ObjectRegistration
    attr_reader :async

    def initialize(listener, options)
      super(listener, options)
      @async = options.fetch(:async, false)
    end

    def broadcast(event, *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.0.1 lib/wisper/async.rb