Skip to content
Browse files

Added on_permanent_failure support to objects called via object.delay…

….do_something
  • Loading branch information...
1 parent 407c2fd commit e04d99e16be967a562284edc46fd2367ab4c3ad8 @dbarros dbarros committed with bkeepers Jul 24, 2010
Showing with 15 additions and 0 deletions.
  1. +8 −0 lib/delayed/performable_method.rb
  2. +7 −0 spec/performable_method_spec.rb
View
8 lib/delayed/performable_method.rb
@@ -15,5 +15,13 @@ def display_name
def perform
object.send(method, *args) if object
end
+
+ def method_missing(symbol, *args)
+ object.respond_to?(symbol) ? object.send(symbol, *args) : super
+ end
+
+ def respond_to?(symbol, include_private=false)
+ object.respond_to?(symbol, include_private) || super
+ end
end
end
View
7 spec/performable_method_spec.rb
@@ -20,6 +20,13 @@
@method.object.should_receive(:count).with('o')
@method.perform
end
+
+ it "should respond to on_permanent_failure when implemented and target object is called via object.delay.do_something" do
+ @method = Delayed::PerformableMethod.new(OnPermanentFailureJob.new, :perform, [])
+ @method.respond_to?(:on_permanent_failure).should be_true
+ @method.object.should_receive(:on_permanent_failure)
+ @method.on_permanent_failure
+ end
end
it "should raise a NoMethodError if target method doesn't exist" do

0 comments on commit e04d99e

Please sign in to comment.
Something went wrong with that request. Please try again.