Class: Galago::Router::DSL

Inherits:
Object
  • Object
show all
Defined in:
lib/galago/router/dsl.rb

Instance Method Summary collapse

Constructor Details

#initialize(router, block) ⇒ DSL

Returns a new instance of DSL.



4
5
6
7
8
# File 'lib/galago/router/dsl.rb', line 4

def initialize(router, block)
  @router = router
  @namespace = ''
  instance_eval(&block)
end

Instance Method Details

#delete(path, options) ⇒ Object



33
34
35
# File 'lib/galago/router/dsl.rb', line 33

def delete(path, options)
  add_route("DELETE", path, options[:to])
end

#get(path, options) ⇒ Object



16
17
18
19
# File 'lib/galago/router/dsl.rb', line 16

def get(path, options)
  add_route("GET", path, options[:to])
  add_route("HEAD", path, Rack::Head.new(options[:to]))
end

#namespace(new_namespace) ⇒ Object



10
11
12
13
14
# File 'lib/galago/router/dsl.rb', line 10

def namespace(new_namespace)
  @namespace << "/#{new_namespace}"
  yield
  @namespace = ''
end

#patch(path, options) ⇒ Object



21
22
23
# File 'lib/galago/router/dsl.rb', line 21

def patch(path, options)
  add_route("PATCH", path, options[:to])
end

#post(path, options) ⇒ Object



25
26
27
# File 'lib/galago/router/dsl.rb', line 25

def post(path, options)
  add_route("POST", path, options[:to])
end

#put(path, options) ⇒ Object



29
30
31
# File 'lib/galago/router/dsl.rb', line 29

def put(path, options)
  add_route("PUT", path, options[:to])
end