Class: Usher::Interface::Rack::Builder
- Inherits:
-
Rack::Builder
- Object
- Rack::Builder
- Usher::Interface::Rack::Builder
- Defined in:
- lib/usher/interface/rack/builder.rb
Overview
Replacement for Builder which using Usher to map requests instead of a simple Hash. As well, add convenience methods for the request methods.
Instance Method Summary collapse
-
#delete(path, options = nil, &block) ⇒ Object
Maps a path with request methods ‘DELETE` to a block.
-
#get(path, options = nil, &block) ⇒ Object
Maps a path with request methods ‘HEAD` and `GET` to a block.
-
#initialize(&block) ⇒ Builder
constructor
A new instance of Builder.
-
#map(path, options = nil, &block) ⇒ Object
Maps a path to a block.
-
#post(path, options = nil, &block) ⇒ Object
Maps a path with request methods ‘POST` to a block.
-
#put(path, options = nil, &block) ⇒ Object
Maps a path with request methods ‘PUT` to a block.
Constructor Details
Instance Method Details
#delete(path, options = nil, &block) ⇒ Object
Maps a path with request methods ‘DELETE` to a block.
50 51 52 |
# File 'lib/usher/interface/rack/builder.rb', line 50 def delete(path, = nil, &block) self.map(path, .merge!(:conditions => {:request_method => "DELETE"}), &block) end |
#get(path, options = nil, &block) ⇒ Object
Maps a path with request methods ‘HEAD` and `GET` to a block.
25 26 27 28 |
# File 'lib/usher/interface/rack/builder.rb', line 25 def get(path, = nil, &block) self.map(path, .merge!(:conditions => {:request_method => "HEAD"}), &block) self.map(path, .merge!(:conditions => {:request_method => "GET"}), &block) end |
#map(path, options = nil, &block) ⇒ Object
Maps a path to a block.
16 17 18 19 |
# File 'lib/usher/interface/rack/builder.rb', line 16 def map(path, = nil, &block) @usher.add(path, ).to(&block) @ins << @usher unless @ins.last == @usher end |
#post(path, options = nil, &block) ⇒ Object
Maps a path with request methods ‘POST` to a block.
34 35 36 |
# File 'lib/usher/interface/rack/builder.rb', line 34 def post(path, = nil, &block) self.map(path, .merge!(:conditions => {:request_method => "POST"}), &block) end |
#put(path, options = nil, &block) ⇒ Object
Maps a path with request methods ‘PUT` to a block.
42 43 44 |
# File 'lib/usher/interface/rack/builder.rb', line 42 def put(path, = nil, &block) self.map(path, .merge!(:conditions => {:request_method => "PUT"}), &block) end |