Skip to content

Commit

Permalink
Allow private methods to be performed in the background
Browse files Browse the repository at this point in the history
  • Loading branch information
bkeepers committed Jul 21, 2010
1 parent 781349e commit a58b2d8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/delayed/performable_method.rb
@@ -1,7 +1,7 @@
module Delayed
class PerformableMethod < Struct.new(:object, :method, :args)
def initialize(object, method, args)
raise NoMethodError, "undefined method `#{method}' for #{object.inspect}" unless object.respond_to?(method)
raise NoMethodError, "undefined method `#{method}' for #{object.inspect}" unless object.respond_to?(method, true)

self.object = object
self.args = args
Expand Down
13 changes: 12 additions & 1 deletion spec/performable_method_spec.rb
Expand Up @@ -22,9 +22,20 @@
end
end

it "should raise a ArgumentError if target method doesn't exist" do
it "should raise a NoMethodError if target method doesn't exist" do
lambda {
Delayed::PerformableMethod.new(Object, :method_that_does_not_exist, [])
}.should raise_error(NoMethodError)
end

it "should not raise NoMethodError if target method is private" do
clazz = Class.new do
def private_method
end
private :private_method
end
lambda {
Delayed::PerformableMethod.new(clazz.new, :private_method, [])
}.should_not raise_error(NoMethodError)
end
end

0 comments on commit a58b2d8

Please sign in to comment.