Class: ZookeeperCallbacks::Callback

Inherits:
Object
  • Object
show all
Defined in:
lib/zookeeper/callbacks.rb

Direct Known Subclasses

ACLCallback, DataCallback, StatCallback, StringCallback, StringsCallback, VoidCallback, WatcherCallback

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Callback) initialize



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

- (Object) completed (readonly)

Returns the value of attribute completed



3
4
5
# File 'lib/zookeeper/callbacks.rb', line 3

def completed
  @completed
end

- (Object) context (readonly)

Returns the value of attribute context



3
4
5
# File 'lib/zookeeper/callbacks.rb', line 3

def context
  @context
end

- (Object) proc (readonly)

Returns the value of attribute proc



3
4
5
# File 'lib/zookeeper/callbacks.rb', line 3

def proc
  @proc
end

Instance Method Details

- (Object) call(*args)



14
15
16
17
# File 'lib/zookeeper/callbacks.rb', line 14

def call(*args)
  # puts "call passed #{args.inspect}"
  @proc.call(*args)
end

- (Boolean) completed?



19
20
21
# File 'lib/zookeeper/callbacks.rb', line 19

def completed?
  @completed
end

- (Object) initialize_context(hash)



23
24
25
# File 'lib/zookeeper/callbacks.rb', line 23

def initialize_context(hash)
  @context = nil
end