Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

use define_method rather than eval for delegation

  • Loading branch information...
commit e6996357a625cf562758567726bf197e48279df5 1 parent 7b49463
@rkh rkh authored
Showing with 5 additions and 7 deletions.
  1. +5 −7 lib/sinatra/base.rb
View
12 lib/sinatra/base.rb
@@ -1467,13 +1467,11 @@ def self.register(*extensions, &block) #:nodoc:
module Delegator #:nodoc:
def self.delegate(*methods)
methods.each do |method_name|
- eval <<-RUBY, binding, '(__DELEGATE__)', 1
- def #{method_name}(*args, &b)
- return super if respond_to? #{method_name.inspect}
- ::Sinatra::Application.send(#{method_name.inspect}, *args, &b)
- end
- private #{method_name.inspect}
- RUBY
+ define_method(method_name) do |*args, &block|
+ return super(*args, &block) if respond_to? method_name
+ ::Sinatra::Application.send(method_name, *args, &block)
+ end
+ private method_name
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.