Class: ZK::EventHandlerSubscription::Base
- Inherits:
-
Object
- Object
- ZK::EventHandlerSubscription::Base
- Includes:
- Logging
- Defined in:
- lib/zk/event_handler_subscription/base.rb
Direct Known Subclasses
Constant Summary collapse
- ALL_EVENTS =
[:created, :deleted, :changed, :child].freeze
- ALL_EVENT_SET =
Set.new(ALL_EVENTS).freeze
Instance Attribute Summary collapse
-
#callback ⇒ Proc
the block associated with the path.
-
#event_handler ⇒ EventHandler
the event handler associated with this subscription.
-
#path ⇒ String
the path this subscription is for.
Instance Method Summary collapse
- #prep_interests(a) ⇒ Object protected
-
#unsubscribe ⇒ Object
(also: #unregister)
unsubscribe from the path or state you were watching.
Instance Attribute Details
#callback ⇒ Proc
the block associated with the path
16 17 18 |
# File 'lib/zk/event_handler_subscription/base.rb', line 16 def callback @callback end |
#event_handler ⇒ EventHandler
the event handler associated with this subscription
8 9 10 |
# File 'lib/zk/event_handler_subscription/base.rb', line 8 def event_handler @event_handler end |
#path ⇒ String
the path this subscription is for
12 13 14 |
# File 'lib/zk/event_handler_subscription/base.rb', line 12 def path @path end |
Instance Method Details
#prep_interests(a) ⇒ Object (protected)
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/zk/event_handler_subscription/base.rb', line 55 def prep_interests(a) # logger.debug { "prep_interests: #{a.inspect}" } return ALL_EVENT_SET if a.nil? rval = case a when Array Set.new(a) when Symbol Set.new([a]) else raise ArgumentError, "Don't know how to handle interests: #{a.inspect}" end rval.tap do |rv| invalid = (rv - ALL_EVENT_SET) raise ArgumentError, "Invalid event name(s) #{invalid.to_a.inspect} given" unless invalid.empty? end end |
#unsubscribe ⇒ Object Also known as: unregister
unsubscribe from the path or state you were watching
38 39 40 |
# File 'lib/zk/event_handler_subscription/base.rb', line 38 def unsubscribe @event_handler.unregister(self) end |