Class: ZK::Subscription::Base
- Inherits:
-
Object
- Object
- ZK::Subscription::Base
- Includes:
- Logger
- Defined in:
- lib/zk/subscription.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#callable ⇒ Object
readonly
the user-supplied callback block, used to create a ThreadedCallback.
-
#parent ⇒ Object
readonly
the object from which we will attempt to #unregister on XXX: need a better name for this.
Instance Method Summary collapse
-
#initialize(parent, block) ⇒ Base
constructor
A new instance of Base.
-
#unregister ⇒ Object
calls unregister on parent, then sets parent to nil.
- #unregistered? ⇒ Boolean
-
#unsubscribe ⇒ Object
an alias for unregister.
Methods included from Logger
#logger, wrapped_logger, wrapped_logger=
Constructor Details
#initialize(parent, block) ⇒ Base
Returns a new instance of Base.
19 20 21 22 23 24 25 |
# File 'lib/zk/subscription.rb', line 19 def initialize(parent, block) raise ArgumentError, "block must repsond_to?(:call)" unless block.respond_to?(:call) raise ArgumentError, "parent must respond_to?(:unregister)" unless parent.respond_to?(:unregister) @parent = parent @callable = block @mutex = Monitor.new end |
Instance Attribute Details
#callable ⇒ Object (readonly)
the user-supplied callback block, used to create a ThreadedCallback
17 18 19 |
# File 'lib/zk/subscription.rb', line 17 def callable @callable end |
#parent ⇒ Object (readonly)
the object from which we will attempt to #unregister on XXX: need a better name for this
14 15 16 |
# File 'lib/zk/subscription.rb', line 14 def parent @parent end |
Instance Method Details
#unregister ⇒ Object
calls unregister on parent, then sets parent to nil
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/zk/subscription.rb', line 32 def unregister obj = nil synchronize do return false unless @parent obj, @parent = @parent, nil end obj.unregister(self) end |
#unregistered? ⇒ Boolean
27 28 29 |
# File 'lib/zk/subscription.rb', line 27 def unregistered? @parent.nil? end |
#unsubscribe ⇒ Object
an alias for unregister
44 45 46 |
# File 'lib/zk/subscription.rb', line 44 def unsubscribe unregister end |