Module: Candygram::Delivery

Defined in:
lib/candygram/delivery.rb

Overview

The special sauce that allows an object to place its method calls into the job queue.

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object

Lazily adds magic Candygram delivery methods to the class.



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/candygram/delivery.rb', line 9

def method_missing(name, *args)
  if name =~ /(\S+)_later$/
    self.class.class_eval <<-LATER
      def #{name}(*args)
        send_candygram("#{$1}", *args)
      end
      LATER
    send(name, *args)
  else
    super
  end
end