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



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

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
20
# 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



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

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

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



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

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

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



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

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

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



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

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