Class: Capybarbecue::AsyncDelegateClass

Inherits:
Object
  • Object
show all
Defined in:
lib/capybarbecue/async_delegate_class.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(instance, executer, &wait_proc) ⇒ AsyncDelegateClass

Returns a new instance of AsyncDelegateClass.



5
6
7
8
9
# File 'lib/capybarbecue/async_delegate_class.rb', line 5

def initialize(instance, executer, &wait_proc)
  @instance = instance
  @executer = executer
  @wait_proc = wait_proc # Called repeatedly while waiting
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



11
12
13
14
15
# File 'lib/capybarbecue/async_delegate_class.rb', line 11

def method_missing(method, *args, &block)
  call = AsyncCall.new(@instance, method, *args, &block)
  @executer.execute(call)
  wrap_response(call.wait_for_response(&@wait_proc))
end

Instance Attribute Details

#instanceObject (readonly)

Returns the value of attribute instance.



3
4
5
# File 'lib/capybarbecue/async_delegate_class.rb', line 3

def instance
  @instance
end

Instance Method Details

#__async_delegate__Object

This is our hint that we are an AsyncDelegateClass



18
19
20
# File 'lib/capybarbecue/async_delegate_class.rb', line 18

def __async_delegate__
  true
end