Class: ZookeeperCallbacks::Callback

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCallback

Returns a new instance of Callback.



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

#completedObject (readonly)

Returns the value of attribute completed.



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

def completed
  @completed
end

#contextObject (readonly)

Returns the value of attribute context.



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

def context
  @context
end

#procObject (readonly)

Returns the value of attribute proc.



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

def proc
  @proc
end

Instance Method Details

#call(*args) ⇒ Object



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

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

#completed?Boolean

Returns:

  • (Boolean)


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

def completed?
  @completed
end

#initialize_context(hash) ⇒ Object



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

def initialize_context(hash)
  @context = nil
end