Class: Core::Async::Wrapper

Inherits:
BasicObject
Defined in:
lib/core/async/wrapper.rb

Overview

public

Wraps an object, calling all methods in an async context.

Instance Method Summary collapse

Constructor Details

#initialize(target) ⇒ Wrapper

Returns a new instance of Wrapper.



8
9
10
11
12
13
14
# File 'lib/core/async/wrapper.rb', line 8

def initialize(target)
  unless target.respond_to?(:async)
    ::Kernel.raise ::ArgumentError, "object is not async-aware"
  end

  @target = target
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missingObject



16
17
18
19
20
# File 'lib/core/async/wrapper.rb', line 16

def method_missing(...)
  @target.async do
    @target.public_send(...)
  end
end

Instance Method Details

#respond_to_missing?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/core/async/wrapper.rb', line 22

def respond_to_missing?(...)
  true
end