Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

! in an included module calling super is more appropriate than

alias_method_chaining
  • Loading branch information...
commit 761c6affa50d62204e2753e2ad3290587896748a 1 parent ef59ac6
Niko Dittmann authored
Showing with 2 additions and 14 deletions.
  1. +2 −14 lib/sinatra/resources.rb
View
16 lib/sinatra/resources.rb
@@ -1,21 +1,9 @@
module Sinatra
module Resources
- def self.registered(app)
- [:get, :post, :put, :delete].each do |meth|
- # http://whynotwiki.com/Ruby_/_Method_aliasing_and_chaining#Can_you_alias_class_methods.3F
- app.class_eval <<-EndAlias
- class << self
- alias_method :#{meth}_without_resource, :#{meth}
- alias_method :#{meth}, :#{meth}_with_resource
- end
- EndAlias
- end
- end
-
[:get, :post, :put, :delete].each do |meth|
class_eval <<-EndMeth
- def #{meth}_with_resource(path=nil, options={}, &block)
- #{meth}_without_resource(make_path(path), options, &block)
+ def #{meth}(path=nil, options={}, &block)
+ super(make_path(path), options, &block)
end
EndMeth
end
Please sign in to comment.
Something went wrong with that request. Please try again.