Sha256: fd595a060da182f4b32192c93d168a69658d1b33f155b7fceb8b191e3ebcd2b7

Contents?: true

Size: 554 Bytes

Versions: 1

Compression:

Stored size: 554 Bytes

Contents

require 'set'

module UV
  module Listener
    @@callbacks = Hash.new { |hash, object_id| hash[object_id] = Hash.new }

    class << self
      def define_callback(object_id, name, callback)
        @@callbacks[object_id][name] ||= callback
      end

      def undefine_callbacks(object_id)
        @@callbacks.delete(object_id)
        nil
      end
    end

    private

    def callback(name)
      Listener.define_callback(object_id, name, method(name))
    end

    def clear_callbacks
      Listener.undefine_callbacks(object_id)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
uvrb-0.2.0 lib/uv/listener.rb