Class: FocusActor::FutureProcessor

Inherits:
Object
  • Object
show all
Defined in:
lib/focus_actor/future_processor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(instance) ⇒ FutureProcessor

Returns a new instance of FutureProcessor.



8
9
10
# File 'lib/focus_actor/future_processor.rb', line 8

def initialize(instance)
  @instance = instance
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



12
13
14
15
16
17
18
19
20
21
# File 'lib/focus_actor/future_processor.rb', line 12

def method_missing(method, *args, &block)
  return super unless instance.respond_to?(method)

  queue = Queue.new
  Thread.new do
    queue.push instance.public_send(method, *args, &block)
  end

  FutureCell.new(queue)
end

Instance Attribute Details

#instanceObject (readonly)

Returns the value of attribute instance.



6
7
8
# File 'lib/focus_actor/future_processor.rb', line 6

def instance
  @instance
end

Instance Method Details

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

Returns:

  • (Boolean)


23
24
25
# File 'lib/focus_actor/future_processor.rb', line 23

def respond_to_missing?(method, include_all = false)
  instance.respond_to?(method) || super
end