Class: Zookeeper::Callbacks::Base
- Inherits:
-
Object
- Object
- Zookeeper::Callbacks::Base
- 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.
Class Method Summary collapse
-
.create ⇒ Object
allows for easier construction of a user callback block that will be called with the callback object itself as an argument.
Instance Method Summary collapse
- #call(*args) ⇒ Object
- #completed? ⇒ Boolean
-
#initialize ⇒ Base
constructor
A new instance of Base.
- #initialize_context(hash) ⇒ Object
Constructor Details
#initialize ⇒ Base
Returns a new instance of Base.
22 23 24 25 26 27 28 29 |
# File 'lib/zookeeper/callbacks.rb', line 22 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.
4 5 6 |
# File 'lib/zookeeper/callbacks.rb', line 4 def completed @completed end |
#context ⇒ Object (readonly)
Returns the value of attribute context.
4 5 6 |
# File 'lib/zookeeper/callbacks.rb', line 4 def context @context end |
#proc ⇒ Object (readonly)
Returns the value of attribute proc.
4 5 6 |
# File 'lib/zookeeper/callbacks.rb', line 4 def proc @proc end |
Class Method Details
.create ⇒ Object
allows for easier construction of a user callback block that will be called with the callback object itself as an argument.
18 19 20 |
# File 'lib/zookeeper/callbacks.rb', line 18 def self.create cb_inst = new { yield cb_inst } end |
Instance Method Details
#call(*args) ⇒ Object
31 32 33 |
# File 'lib/zookeeper/callbacks.rb', line 31 def call(*args) @proc.call(*args) end |
#completed? ⇒ Boolean
35 36 37 |
# File 'lib/zookeeper/callbacks.rb', line 35 def completed? @completed end |
#initialize_context(hash) ⇒ Object
39 40 41 |
# File 'lib/zookeeper/callbacks.rb', line 39 def initialize_context(hash) @context = nil end |