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 Attribute Summary

Attributes inherited from Base

#context, #req_id

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



174
175
176
177
178
179
180
181
182
# File 'lib/z_k/z_k_event_machine/callback.rb', line 174

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



187
188
189
190
# File 'lib/z_k/z_k_event_machine/callback.rb', line 187

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