Module: Wayfarer::Routing::DSL

Included in:
Route
Defined in:
lib/wayfarer/routing/dsl.rb

Instance Method Summary collapse

Instance Method Details

#custom(delegate, options = {}, &block) ⇒ Object



39
40
41
# File 'lib/wayfarer/routing/dsl.rb', line 39

def custom(delegate, options = {}, &block)
  add_child_route(Matchers::Custom.new(delegate), path_offset, options, &block)
end

#host(host, options = {}, &block) ⇒ Object



10
11
12
# File 'lib/wayfarer/routing/dsl.rb', line 10

def host(host, options = {}, &block)
  add_child_route(Matchers::Host.new(host), path_offset, options, &block)
end

#path(path, options = {}, &block) ⇒ Object



14
15
16
17
18
19
# File 'lib/wayfarer/routing/dsl.rb', line 14

def path(path, options = {}, &block)
  offset = File.join(path_offset, path)
  add_child_route(nil, offset, options, &block).tap do |route|
    route.matcher = Matchers::Path.new(offset, route)
  end
end

#query(fields, options = {}, &block) ⇒ Object



21
22
23
# File 'lib/wayfarer/routing/dsl.rb', line 21

def query(fields, options = {}, &block)
  add_child_route(Matchers::Query.new(fields), path_offset, options, &block)
end

#scheme(scheme, options = {}, &block) ⇒ Object



25
26
27
# File 'lib/wayfarer/routing/dsl.rb', line 25

def scheme(scheme, options = {}, &block)
  add_child_route(Matchers::Scheme.new(scheme), path_offset, options, &block)
end

#suffix(suffix, options = {}, &block) ⇒ Object



29
30
31
# File 'lib/wayfarer/routing/dsl.rb', line 29

def suffix(suffix, options = {}, &block)
  add_child_route(Matchers::Suffix.new(suffix), path_offset, options, &block)
end

#to(action, options = {}, &block) ⇒ Object



33
34
35
36
37
# File 'lib/wayfarer/routing/dsl.rb', line 33

def to(action, options = {}, &block)
  add_child_route(Matchers::Custom.new { true }, path_offset, TargetRoute, options, &block).tap do |route|
    route.action = action
  end
end

#url(url, options = {}, &block) ⇒ Object



6
7
8
# File 'lib/wayfarer/routing/dsl.rb', line 6

def url(url, options = {}, &block)
  add_child_route(Matchers::URL.new(url), path_offset, options, &block)
end