Class: ZK::EventHandlerSubscription::Base

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/zk/event_handler_subscription/base.rb

Direct Known Subclasses

Actor

Constant Summary collapse

ALL_EVENTS =
[:created, :deleted, :changed, :child].freeze
ALL_EVENT_SET =
Set.new(ALL_EVENTS).freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#callbackProc

the block associated with the path

Returns:

  • (Proc)


16
17
18
# File 'lib/zk/event_handler_subscription/base.rb', line 16

def callback
  @callback
end

#event_handlerEventHandler

the event handler associated with this subscription

Returns:



8
9
10
# File 'lib/zk/event_handler_subscription/base.rb', line 8

def event_handler
  @event_handler
end

#pathString

the path this subscription is for

Returns:

  • (String)


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

#unsubscribeObject 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