Module: ZK::Extensions::Callbacks::Callback::ClassMethods

Defined in:
lib/zk/extensions.rb

Instance Method Summary collapse

Instance Method Details

#create(*args, &block) ⇒ Object

allows for easier construction of a user callback block that will be called with the callback object itself as an argument.

args, if given, will be passed on *after the callback

Examples:


WatcherCallback.create do |cb|
  puts "watcher callback called with argument: #{cb.inspect}"
end

"watcher callback called with argument: #<ZookeeperCallbacks::WatcherCallback:0x1018a3958 @state=3, @type=1, ...>"


59
60
61
# File 'lib/zk/extensions.rb', line 59

def create(*args, &block)
  cb_inst = new { block.call(cb_inst) }
end