Module: Sinatra::Verbs
- Defined in:
- lib/sinatra/verbs.rb
Class Method Summary collapse
-
.custom(*verbs) ⇒ Object
Defines custom HTTP verbs.
Class Method Details
.custom(*verbs) ⇒ Object
Defines custom HTTP verbs.
This method exposes enough API to use this custom verbs in both Sinatra styles: the classic one, and inheriting Sinatra::Base. You work with them as if they were regular HTTP verbs.
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/sinatra/verbs.rb', line 7 def self.custom(*verbs) verbs.each do |verb_name| ::Sinatra::Delegator.module_eval " def \#{verb_name}(*args, &b)\n ::Sinatra::Application.send(\#{verb_name.inspect}, *args, &b)\n end\n private \#{verb_name.inspect}\n RUBY\n ::Sinatra::Base.module_eval <<-RUBY\n def self.\#{verb_name}(path, opts={}, &bk); route '\#{verb_name.to_s.upcase}', path, opts, &bk end\n RUBY\n end\nend\n" |