Sha256: 02f6a94113f171180ee273cb8ef6eeec6dd8e0563afc7029baf5c489895afb3e

Contents?: true

Size: 629 Bytes

Versions: 2

Compression:

Stored size: 629 Bytes

Contents

module Wisper
  module Async
    class Listener
      include Celluloid

      attr_reader :listener, :event_method

      def initialize(listener, event_method)
        @listener     = listener
        @event_method = event_method.to_sym
      end

      def method_missing(method, *args, &block)
        if listener.respond_to?(method)
          if method == event_method
            listener.public_send(method, *args, &block)
            terminate
          else
            listener.public_send(method, *args, &block)
          end
        else
          super(method, *args, &block)
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

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