Class: DelayedFu::DelayedMethod

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

Instance Method Summary collapse

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

Raises:

  • (NoMethodError)


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

Returns:

  • (Boolean)


14
15
16
# File 'lib/delayed_fu.rb', line 14

def respond_to?(method_name, *args, &block)
  @target.respond_to?(method_name)
end