collectiveidea/delayed_job — Issue #306: Class methods not being called since "undefined method `xyz' for Class:Class"
Author: gorenje
Created: 2011-11-18 10:34:36+00:00
State: open

Hi,

i'm using DJ to delay calls to class methods. This worked fine with DJ 2.1.4 + MySql, but with DJ 3.0.0.pre4 + Mongo (i.e. delayed_job_mongoid 1.0.6, mongodb 2.0.0) i'm getting an undefined method for Class:Class, i.e. the class-of-the-class that i want to be calling.

Basically this is what happening:

class Event
def self.happened(...)
doing_stuff
end
end
Event.delay.happened(...)

Then when i look at the handler:

ruby-1.9.2-p180 :020 > YAML.parse(Delayed::Job.first.handler)["object"].value
=> "Event"
ruby-1.9.2-p180 :021 > YAML.parse(Delayed::Job.first.handler)["method_name"].value
=> ":happened"

i.e. the object is the Event class (as it should) and method name is correct, however when i retrieve the payload object:

ruby-1.9.2-p180 :025 > Delayed::Job.first.payload_object.object
=> Class
ruby-1.9.2-p180 :026 > Delayed::Job.first.payload_object.method_name
=> :happened

If i repeat the above using DJ 2.1.4 + mysql (same ruby version - 1.9.2-p180):

>> YAML.parse(Delayed::Job.first.handler)["object"].value
=> "Event"
>> YAML.parse(Delayed::Job.first.handler)["method_name"].value
=> ":happened"
>> Delayed::Job.first.payload_object.object
=> Event
>> Delayed::Job.first.payload_object.method_name
=> :happened

Is delaying class methods no longer supported? Or is this a real issue?

Thanks!