Class: Expressr::Route

Inherits:
Object
  • Object
show all
Defined in:
lib/expressr/route.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Route

Returns a new instance of Route.



3
4
5
6
# File 'lib/expressr/route.rb', line 3

def initialize(options={})
  @router = options[:router] || raise('No router provided')
  @path = options[:path] || raise('No path provided')
end

Instance Method Details

#all(&block) ⇒ Object



8
9
10
11
# File 'lib/expressr/route.rb', line 8

def all(&block)
  @router.add_route(block, path: @path)
  self
end

#delete(&block) ⇒ Object



28
29
30
31
# File 'lib/expressr/route.rb', line 28

def delete(&block)
  @router.delete(@path, &block)
  self
end

#get(&block) ⇒ Object



13
14
15
16
# File 'lib/expressr/route.rb', line 13

def get(&block)
  @router.get(@path, &block)
  self
end

#post(&block) ⇒ Object



23
24
25
26
# File 'lib/expressr/route.rb', line 23

def post(&block)
  @router.post(@path, &block)
  self
end

#put(&block) ⇒ Object



18
19
20
21
# File 'lib/expressr/route.rb', line 18

def put(&block)
  @router.put(@path, &block)
  self
end