Skip to content

Commit

Permalink
use respond_to? rather than arity checks to play nice with method_mis…
Browse files Browse the repository at this point in the history
…sing proxies

Conflicts:

	lib/sinatra/base.rb
	test/delegator_test.rb
  • Loading branch information
rkh committed Apr 17, 2011
1 parent fafc797 commit 5fa4a15
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions lib/sinatra/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1478,14 +1478,7 @@ def self.delegate(*methods)
methods.each do |method_name|
eval <<-RUBY, binding, '(__DELEGATE__)', 1
def #{method_name}(*args, &b)
arity = ::Sinatra::Delegator.target.method(#{method_name.inspect}).arity
if arity < 0 ? args.size < -arity - 1 : args.size != arity
begin
return super
rescue NameError => e
raise e unless e.message.include? #{method_name.to_s.inspect}
end
end
return super if respond_to? #{method_name.inspect}
::Sinatra::Application.send(#{method_name.inspect}, *args, &b)
end
private #{method_name.inspect}
Expand Down

0 comments on commit 5fa4a15

Please sign in to comment.