lib/roda/plugins/all_verbs.rb in roda-1.1.0 vs lib/roda/plugins/all_verbs.rb in roda-1.2.0
- old
+ new
@@ -4,14 +4,13 @@
# get and post. The following verbs are added, assuming
# rack handles them: delete, head, options, link, patch, put,
# trace, unlink.
#
# These methods operate just like Roda's default get and post
- # methods other that the http verb used, so using them without
- # any arguments just checks for the request method, while
- # using them with any arguments also checks that the arguments
- # match the full path.
+ # methods, so using them without any arguments just checks for
+ # the request method, while using them with any arguments also
+ # checks that the arguments match the full path.
#
# Example:
#
# plugin :all_verbs
#
@@ -28,15 +27,17 @@
# end
#
# The verb methods are defined via metaprogramming, so there
# isn't documentation for the individual methods created.
module AllVerbs
- def self.configure(app)
- %w'delete head options link patch put trace unlink'.each do |v|
- if ::Rack::Request.method_defined?("#{v}?")
- app.request_module do
- app::RodaRequest.def_verb_method(self, v)
- end
+ module RequestMethods
+ %w'delete head options link patch put trace unlink'.each do |verb|
+ if ::Rack::Request.method_defined?("#{verb}?")
+ class_eval(<<-END, __FILE__, __LINE__+1)
+ def #{verb}(*args, &block)
+ _verb(args, &block) if #{verb}?
+ end
+ END
end
end
end
end