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 <<-RUBY def #{verb_name}(*args, &b) ::Sinatra::Application.send(#{verb_name.inspect}, *args, &b) end private #{verb_name.inspect} RUBY ::Sinatra::Base.module_eval <<-RUBY def self.#{verb_name}(path, opts={}, &bk); route '#{verb_name.to_s.upcase}', path, opts, &bk end RUBY end end |