Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

enable send_later for module methods #42

Merged
merged 1 commit into from

2 participants

mnemonikk Tobias Lütke
mnemonikk

I made a patch to enable send_later not only for class methods but for module methods as well. There's an issue for that already, but it didn't get fixed yet.

Tobias Lütke tobi merged commit 7da8b83 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 23, 2011
  1. make send_later work for module methods

    helbig@mediapeers.com authored
This page is out of date. Refresh to see the latest.
Showing with 16 additions and 2 deletions.
  1. +2 −2 lib/delayed/performable_method.rb
  2. +14 −0 spec/delayed_method_spec.rb
4 lib/delayed/performable_method.rb
View
@@ -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
@@ -52,4 +52,4 @@ def class_to_string(obj)
"CLASS:#{obj.name}"
end
end
-end
+end
14 spec/delayed_method_spec.rb
View
@@ -11,6 +11,12 @@ def say_hello
end
end
+module RandomModule
+ def self.say_hello
+ 'hello'
+ end
+end
+
class ErrorObject
def throw
@@ -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...'
Something went wrong with that request. Please try again.