Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable send_later for module methods #42

Merged
merged 1 commit into from Aug 11, 2011
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/delayed/performable_method.rb
Expand Up @@ -38,7 +38,7 @@ def load(arg)


def dump(arg) def dump(arg)
case 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) when ActiveRecord::Base then ar_to_string(arg)
else arg else arg
end end
Expand All @@ -52,4 +52,4 @@ def class_to_string(obj)
"CLASS:#{obj.name}" "CLASS:#{obj.name}"
end end
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
end end


module RandomModule
def self.say_hello
'hello'
end
end

class ErrorObject class ErrorObject


def throw def throw
Expand Down Expand Up @@ -110,6 +116,14 @@ def read(story)
job.payload_object.perform.should == 'Epilog: Once upon...' job.payload_object.perform.should == 'Epilog: Once upon...'
end 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 it "should call send later on methods which are wrapped with handle_asynchronously" do
story = Story.create :text => 'Once upon...' story = Story.create :text => 'Once upon...'


Expand Down