Skip to content

Commit

Permalink
Merge pull request tobi#42 from mnemonikk/master
Browse files Browse the repository at this point in the history
enable send_later for module methods
  • Loading branch information
Tobias Lütke committed Aug 11, 2011
2 parents d9165b9 + a67dc38 commit 7da8b83
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/delayed/performable_method.rb
Expand Up @@ -38,7 +38,7 @@ def load(arg)

def dump(arg)
case arg
when Class then class_to_string(arg)
when Class, Module then class_to_string(arg)
when ActiveRecord::Base then ar_to_string(arg)
else arg
end
Expand All @@ -52,4 +52,4 @@ def class_to_string(obj)
"CLASS:#{obj.name}"
end
end
end
end
14 changes: 14 additions & 0 deletions spec/delayed_method_spec.rb
Expand Up @@ -11,6 +11,12 @@ def say_hello
end
end

module RandomModule
def self.say_hello
'hello'
end
end

class ErrorObject

def throw
Expand Down Expand Up @@ -110,6 +116,14 @@ def read(story)
job.payload_object.perform.should == 'Epilog: Once upon...'
end

it "should store the object as string if it's a module" do
RandomModule.send_later(:say_hello)
job = Delayed::Job.find(:first)
job.payload_object.method.should == :say_hello
job.payload_object.object.should == "CLASS:RandomModule"
job.payload_object.perform.should == 'hello'
end

it "should call send later on methods which are wrapped with handle_asynchronously" do
story = Story.create :text => 'Once upon...'

Expand Down

0 comments on commit 7da8b83

Please sign in to comment.