Class: DelayedFu::DelayedMethod
- Inherits:
-
Object
- Object
- DelayedFu::DelayedMethod
- Defined in:
- lib/delayed_fu.rb
Instance Method Summary collapse
-
#initialize(target) ⇒ DelayedMethod
constructor
A new instance of DelayedMethod.
- #method_missing(method_name, *args, &block) ⇒ Object
- #respond_to?(method_name, *args, &block) ⇒ Boolean
Constructor Details
#initialize(target) ⇒ DelayedMethod
Returns a new instance of DelayedMethod.
10 11 12 |
# File 'lib/delayed_fu.rb', line 10 def initialize(target) @target = target end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/delayed_fu.rb', line 18 def method_missing(method_name, *args, &block) raise NoMethodError.new("undefined method `#{method_name}' for #{@target.inspect}") unless respond_to?(method_name, *args, &block) if @target.class == Class && defined?(Job) Job.enqueue!(@target.to_s, "class.#{method_name}", *args) else Job.enqueue!(@target.class.to_s, method_name.to_s, *args) end end |
Instance Method Details
#respond_to?(method_name, *args, &block) ⇒ Boolean
14 15 16 |
# File 'lib/delayed_fu.rb', line 14 def respond_to?(method_name, *args, &block) @target.respond_to?(method_name) end |