Class: Mayu::Routing::Routes::Route
- Inherits:
-
Object
- Object
- Mayu::Routing::Routes::Route
- Extended by:
- T::Sig
- Defined in:
- lib/mayu/routing/routes.rb
Instance Attribute Summary collapse
-
#layout ⇒ Object
Returns the value of attribute layout.
-
#not_found ⇒ Object
Returns the value of attribute not_found.
-
#page ⇒ Object
Returns the value of attribute page.
Instance Method Summary collapse
- #add_route(route) ⇒ Object
-
#initialize ⇒ Route
constructor
A new instance of Route.
- #match(part) ⇒ Object
- #match?(part) ⇒ Boolean
Constructor Details
Instance Attribute Details
#layout ⇒ Object
Returns the value of attribute layout.
13 14 15 |
# File 'lib/mayu/routing/routes.rb', line 13 def layout @layout end |
#not_found ⇒ Object
Returns the value of attribute not_found.
15 16 17 |
# File 'lib/mayu/routing/routes.rb', line 15 def not_found @not_found end |
#page ⇒ Object
Returns the value of attribute page.
11 12 13 |
# File 'lib/mayu/routing/routes.rb', line 11 def page @page end |
Instance Method Details
#add_route(route) ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/mayu/routing/routes.rb', line 27 def add_route(route) case route when Named @named[route.name] = route when Param @params.push(route) else raise TypeError, "Unknown route type: #{route.class}" end end |
#match(part) ⇒ Object
39 40 41 |
# File 'lib/mayu/routing/routes.rb', line 39 def match(part) @named.fetch(part) { @params.find { _1.match?(part) } } end |
#match?(part) ⇒ Boolean
44 45 46 |
# File 'lib/mayu/routing/routes.rb', line 44 def match?(part) true end |