Class: ZK::ZKEventMachine::Callback::ExistsCallback

Inherits:
StatCallback show all
Defined in:
lib/z_k/z_k_event_machine/callback.rb

Overview

supports the syntactic sugar exists? call

Instance Method Summary collapse

Methods inherited from StatCallback

#success?

Methods inherited from Base

async_result_keys, #async_result_keys, #call, #check_async_rc, #exception_for, #initialize, #on_result, #success?

Constructor Details

This class inherits a constructor from ZK::ZKEventMachine::Callback::Base

Instance Method Details

#deferred_style_result(hash) ⇒ Object

This method is abstract.

should call set_deferred_status with the appropriate args for the result and type of call



164
165
166
167
168
169
170
171
172
# File 'lib/z_k/z_k_event_machine/callback.rb', line 164

def deferred_style_result(hash)
  # ensure this calls the callback on the reactor

  if success?(hash)
    succeed(hash[:stat].exists?)
  else
    fail(exception_for(hash))
  end
end

#node_style_result(hash) ⇒ Object

call the user block with the correct Exception class as the first arg (or nil if no error) and then the appropriate args for the type of asynchronous call



177
178
179
180
# File 'lib/z_k/z_k_event_machine/callback.rb', line 177

def node_style_result(hash)
  return unless @block
  @block.call(exception_for(hash), hash[:stat].exists?)
end