### Home Classes Methods

### In Files

- lib/cool.io/meta.rb

### Methods

- #event_callback
- #watcher_delegate

### Class/Module Index

Quicksearch

- Coolio
- Coolio::AsyncWatcher
- Coolio::Connections
- Coolio::DNSResolver
- Coolio::DNSResolver::Timeout
- Coolio::DSL
- Coolio::DSL::ConnectionBuilder
- Coolio::IO
- Coolio::IO::Watcher
- Coolio::IOWatcher
- Coolio::Listener
- Coolio::Loop
- Coolio::Meta
- Coolio::Server
- Coolio::Socket
- Coolio::Socket::Connector
- Coolio::TCPListener
- Coolio::TCPServer
- Coolio::TCPSocket
- Coolio::TCPSocket::TCPConnectResolver
- Coolio::TCPSocket::TCPConnectSocket
- Coolio::TimerWatcher
- Coolio::UNIXListener
- Coolio::UNIXServer
- Coolio::UNIXSocket
- Cool
- Cool::Coolness
- Cool::IOThunk
- Object
- Thread

No matching classes.

# Coolio::Meta

### Public Instance Methods

event_callback(*methods) click to toggle source

Define callbacks whose behavior can be changed on-the-fly per instance. This is done by giving a block to the callback method, which is captured as a proc and stored for later. If the method is called without a block, the stored block is executed if present, otherwise it's a noop.

    # File lib/cool.io/meta.rb, line 32
    def event_callback(*methods)
      methods.each do |method|
        module_eval           def #{method}(*args, &block)            if block              @#{method}_callback = block              return            end            if defined? @#{method}_callback and @#{method}_callback              @#{method}_callback.call(*args)            end          end
      end
    end

watcher_delegate(proxy_var) click to toggle source

Use an alternate watcher with the attach/detach/enable/disable methods if it is presently assigned. This is useful if you are waiting for an event to occur before the current watcher can be used in earnest, such as making an outgoing TCP connection.

    # File lib/cool.io/meta.rb, line 13
    def watcher_delegate(proxy_var)
      %{attach attached? detach enable disable}.each do |method|
        module_eval           def #{method}(*args)            if defined? #{proxy_var} and #{proxy_var}              #{proxy_var}.#{method}(*args)              return self            end            super          end
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.