Class: Parallizer::Proxy
- Inherits:
-
Object
- Object
- Parallizer::Proxy
- Defined in:
- lib/parallizer/proxy.rb
Instance Method Summary collapse
-
#initialize(client, call_infos) ⇒ Proxy
constructor
A new instance of Proxy.
- #method_missing(name, *args, &block) ⇒ Object
- #respond_to?(name, include_private = false, &block) ⇒ Boolean
Constructor Details
#initialize(client, call_infos) ⇒ Proxy
Returns a new instance of Proxy.
6 7 8 9 |
# File 'lib/parallizer/proxy.rb', line 6 def initialize(client, call_infos) @client = client @call_infos = call_infos end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/parallizer/proxy.rb', line 11 def method_missing(name, *args, &block) if call_info = @call_infos[[name, *args]] if call_info[:exception] # add the current call stack to the exception backtrace exception = call_info[:exception].clone exception.set_backtrace((call_info[:exception].backtrace || []) + caller) raise exception else call_info[:result] end else @client.send(*[name, *args], &block) end end |
Instance Method Details
#respond_to?(name, include_private = false, &block) ⇒ Boolean
26 27 28 29 30 31 32 33 34 |
# File 'lib/parallizer/proxy.rb', line 26 def respond_to?(name, include_private = false, &block) @execution_methods ||= Set.new(@call_infos.keys.collect(&:first)) if @execution_methods.include?(name.to_sym) true else super end end |