Sha256: c9d37ff4037497dd5c98ff60b9a81532501802696aeb45a544a03fc5df8ca782

Contents?: true

Size: 499 Bytes

Versions: 1

Compression:

Stored size: 499 Bytes

Contents

module Wisper
  class ObjectRegistration < Registration
    attr_reader :with

    def initialize(listener, options)
      super(listener, options)
      @with = options[:with]
    end

    def broadcast(event, *args)
      method_to_call = map_event_to_method(event)
      if should_broadcast?(event) && listener.respond_to?(method_to_call)
        listener.public_send(method_to_call, *args)
      end
    end

    private

    def map_event_to_method(event)
      with || event
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wisper-1.0.0 lib/wisper/registration/object.rb