123456789_123456789_123456789_123456789_123456789_

Class: Concurrent::Async::AwaitDelegator

Relationships & Source Files
Inherits: Object
Defined in: lib/concurrent-ruby/concurrent/async.rb

Overview

Delegates synchronous, thread-safe method calls to the wrapped object.

Class Method Summary

Instance Method Summary

Constructor Details

.new(delegate) ⇒ AwaitDelegator

Create a new delegator object wrapping the given delegate.

Parameters:

  • delegate (AsyncDelegator)

    the object to wrap and delegate method calls to

[ GitHub ]

  
# File 'lib/concurrent-ruby/concurrent/async.rb', line 365

def initialize(delegate)
  @delegate = delegate
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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

Delegates method calls to the wrapped object.

Parameters:

  • method (Symbol)

    the method being called

  • args (Array)

    zero or more arguments to the method

Returns:

  • (IVar)

    the result of the method call

Raises:

  • (NameError)

    the object does not respond to method method

  • (ArgumentError)

    the given args do not match the arity of method

[ GitHub ]

  
# File 'lib/concurrent-ruby/concurrent/async.rb', line 378

def method_missing(method, *args, &block)
  ivar = @delegate.send(method, *args, &block)
  ivar.wait
  ivar
end

Instance Method Details

#respond_to_missing?(method, include_private = false) ⇒ Boolean

Check whether the method is responsive

Parameters:

  • method (Symbol)

    the method being called

[ GitHub ]

  
# File 'lib/concurrent-ruby/concurrent/async.rb', line 387

def respond_to_missing?(method, include_private = false)
  @delegate.respond_to?(method) || super
end