Class: Shackleton::Route
- Inherits:
-
Object
- Object
- Shackleton::Route
- Extended by:
- Forwardable
- Defined in:
- lib/shackleton/route.rb
Instance Method Summary collapse
-
#initialize(name: nil, path: nil, parent: nil, **options, &block) ⇒ Route
constructor
A new instance of Route.
- #named_fragments ⇒ Object
- #route(name, path = nil, **options, &block) ⇒ Object
- #routes ⇒ Object
Constructor Details
#initialize(name: nil, path: nil, parent: nil, **options, &block) ⇒ Route
Returns a new instance of Route.
8 9 10 11 12 13 14 |
# File 'lib/shackleton/route.rb', line 8 def initialize(name: nil, path: nil, parent: nil, **, &block) @name = name @path = path || name.to_s = @parent = parent instance_exec self, &block if block_given? end |
Instance Method Details
#named_fragments ⇒ Object
24 25 26 |
# File 'lib/shackleton/route.rb', line 24 def named_fragments @named_fragments ||= pattern.names.map(&:to_sym) end |
#route(name, path = nil, **options, &block) ⇒ Object
16 17 18 |
# File 'lib/shackleton/route.rb', line 16 def route(name, path=nil, **, &block) routes[name.to_sym] = self.class.new(name: name, path: path, **, &block) end |
#routes ⇒ Object
20 21 22 |
# File 'lib/shackleton/route.rb', line 20 def routes @routes ||= {} end |