Module: Wayfarer::Routing::DSL
- Included in:
- Route
- Defined in:
- lib/wayfarer/routing/dsl.rb
Instance Method Summary collapse
- #custom(delegate, options = {}, &block) ⇒ Object
- #host(host, options = {}, &block) ⇒ Object
- #path(path, options = {}, &block) ⇒ Object
- #query(fields, options = {}, &block) ⇒ Object
- #scheme(scheme, options = {}, &block) ⇒ Object
- #suffix(suffix, options = {}, &block) ⇒ Object
- #to(action, options = {}, &block) ⇒ Object
- #url(url, options = {}, &block) ⇒ Object
Instance Method Details
#custom(delegate, options = {}, &block) ⇒ Object
39 40 41 |
# File 'lib/wayfarer/routing/dsl.rb', line 39 def custom(delegate, = {}, &block) add_child_route(Matchers::Custom.new(delegate), path_offset, , &block) end |
#host(host, options = {}, &block) ⇒ Object
10 11 12 |
# File 'lib/wayfarer/routing/dsl.rb', line 10 def host(host, = {}, &block) add_child_route(Matchers::Host.new(host), path_offset, , &block) end |
#path(path, options = {}, &block) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/wayfarer/routing/dsl.rb', line 14 def path(path, = {}, &block) offset = File.join(path_offset, path) add_child_route(nil, offset, , &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, = {}, &block) add_child_route(Matchers::Query.new(fields), path_offset, , &block) end |
#scheme(scheme, options = {}, &block) ⇒ Object
25 26 27 |
# File 'lib/wayfarer/routing/dsl.rb', line 25 def scheme(scheme, = {}, &block) add_child_route(Matchers::Scheme.new(scheme), path_offset, , &block) end |
#suffix(suffix, options = {}, &block) ⇒ Object
29 30 31 |
# File 'lib/wayfarer/routing/dsl.rb', line 29 def suffix(suffix, = {}, &block) add_child_route(Matchers::Suffix.new(suffix), path_offset, , &block) end |
#to(action, options = {}, &block) ⇒ Object
33 34 35 36 37 |
# File 'lib/wayfarer/routing/dsl.rb', line 33 def to(action, = {}, &block) add_child_route(Matchers::Custom.new { true }, path_offset, TargetRoute, , &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, = {}, &block) add_child_route(Matchers::URL.new(url), path_offset, , &block) end |