Class: Usher::Interface::Rack::Builder

Inherits:
Rack::Builder
  • Object
show all
Defined in:
lib/usher/interface/rack.rb

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ Builder

Returns a new instance of Builder.



8
9
10
11
# File 'lib/usher/interface/rack.rb', line 8

def initialize(&block)
  @usher = Usher::Interface::Rack.new
  super
end

Instance Method Details

#delete(path, options = nil, &block) ⇒ Object



33
34
35
# File 'lib/usher/interface/rack.rb', line 33

def delete(path, options = nil, &block)
  self.map(path, options.merge!(:conditions => {:request_method => "DELETE"}), &block)
end

#get(path, options = nil, &block) ⇒ Object

it returns route, and because you may want to work with the route, for example give it a name, we returns the route with GET request



20
21
22
23
# File 'lib/usher/interface/rack.rb', line 20

def get(path, options = nil, &block)
  self.map(path, options.merge!(:conditions => {:request_method => "HEAD"}), &block)
  self.map(path, options.merge!(:conditions => {:request_method => "GET"}), &block)
end

#map(path, options = nil, &block) ⇒ Object



13
14
15
16
# File 'lib/usher/interface/rack.rb', line 13

def map(path, options = nil, &block)
  @usher.add(path, options).to(&block)
  @ins << @usher unless @ins.last == @usher
end

#post(path, options = nil, &block) ⇒ Object



25
26
27
# File 'lib/usher/interface/rack.rb', line 25

def post(path, options = nil, &block)
  self.map(path, options.merge!(:conditions => {:request_method => "POST"}), &block)
end

#put(path, options = nil, &block) ⇒ Object



29
30
31
# File 'lib/usher/interface/rack.rb', line 29

def put(path, options = nil, &block)
  self.map(path, options.merge!(:conditions => {:request_method => "PUT"}), &block)
end