Class: Threadless::Executor
- Inherits:
-
Object
- Object
- Threadless::Executor
- Defined in:
- lib/threadless.rb
Overview
This replaces the metal body piece. It intercepts all messages and adjusts “close” in such a way that close closes the original body, and then executes all the procs that are passed into the c’tor.
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(body, procs) ⇒ Executor
constructor
A new instance of Executor.
- #method_missing(sym, *args, &block) ⇒ Object
Constructor Details
#initialize(body, procs) ⇒ Executor
Returns a new instance of Executor.
43 44 45 |
# File 'lib/threadless.rb', line 43 def initialize(body, procs) @body, @procs = body, procs end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args, &block) ⇒ Object
39 40 41 |
# File 'lib/threadless.rb', line 39 def method_missing(sym, *args, &block) @body.__send__ sym, *args, &block end |
Instance Method Details
#close ⇒ Object
47 48 49 50 51 52 53 54 55 56 |
# File 'lib/threadless.rb', line 47 def close return if @closed @closed = true @body.close if @body.respond_to?(:close) @procs.each do |proc| proc.call end end |