Class: ZookeeperCallbacks::Callback
- Inherits:
-
Object
- Object
- ZookeeperCallbacks::Callback
- Defined in:
- lib/zookeeper/callbacks.rb
Direct Known Subclasses
ACLCallback, DataCallback, StatCallback, StringCallback, StringsCallback, VoidCallback, WatcherCallback
Instance Attribute Summary collapse
-
#completed ⇒ Object
readonly
Returns the value of attribute completed.
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#proc ⇒ Object
readonly
Returns the value of attribute proc.
Instance Method Summary collapse
- #call(*args) ⇒ Object
- #completed? ⇒ Boolean
-
#initialize ⇒ Callback
constructor
A new instance of Callback.
- #initialize_context(hash) ⇒ Object
Constructor Details
#initialize ⇒ Callback
Returns a new instance of Callback.
5 6 7 8 9 10 11 12 |
# File 'lib/zookeeper/callbacks.rb', line 5 def initialize @completed = false @proc = Proc.new do |hash| initialize_context(hash) yield if block_given? @completed = true end end |
Instance Attribute Details
#completed ⇒ Object (readonly)
Returns the value of attribute completed.
3 4 5 |
# File 'lib/zookeeper/callbacks.rb', line 3 def completed @completed end |
#context ⇒ Object (readonly)
Returns the value of attribute context.
3 4 5 |
# File 'lib/zookeeper/callbacks.rb', line 3 def context @context end |
#proc ⇒ Object (readonly)
Returns the value of attribute proc.
3 4 5 |
# File 'lib/zookeeper/callbacks.rb', line 3 def proc @proc end |
Instance Method Details
#call(*args) ⇒ Object
14 15 16 17 |
# File 'lib/zookeeper/callbacks.rb', line 14 def call(*args) # puts "call passed #{args.inspect}" @proc.call(*args) end |
#completed? ⇒ Boolean
19 20 21 |
# File 'lib/zookeeper/callbacks.rb', line 19 def completed? @completed end |
#initialize_context(hash) ⇒ Object
23 24 25 |
# File 'lib/zookeeper/callbacks.rb', line 23 def initialize_context(hash) @context = nil end |