Class: Shackleton::Route

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/shackleton/route.rb

Instance Method Summary collapse

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, **options, &block)
  @name     = name
  @path     = path || name.to_s
  @options  = options
  @parent   = parent
  instance_exec self, &block if block_given?
end

Instance Method Details

#named_fragmentsObject



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, **options, &block)
  routes[name.to_sym] = self.class.new(name: name, path: path, **options, &block)
end

#routesObject



20
21
22
# File 'lib/shackleton/route.rb', line 20

def routes
  @routes ||= {}
end