Class: Silicon::Routing::Builder
- Inherits:
-
Object
- Object
- Silicon::Routing::Builder
- Defined in:
- lib/silicon/routing/builder.rb
Instance Method Summary collapse
- #build(sections) ⇒ Object
-
#initialize ⇒ Builder
constructor
A new instance of Builder.
Constructor Details
#initialize ⇒ Builder
Returns a new instance of Builder.
6 7 8 9 10 11 |
# File 'lib/silicon/routing/builder.rb', line 6 def initialize @parsed_items = [] @route_params = [] @current_parent = nil @prev_route = nil end |
Instance Method Details
#build(sections) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/silicon/routing/builder.rb', line 13 def build(sections) result = [] node = sections.node restore_hierarchy(node, nil, node.to_hash) @route_params.each do |route| if route[:actions] route[:actions].each do |action| result << Route.new({ path: restore_path(route).gsub('$', '/$'), params: restore_params(route).map{|p| p.sub('$', '')}, http_verb: action[:http_verb], view: action[:view], http_status: action[:http_status], catch: sections.catch.command, commands: restore_callbacks(route, :before) + action[:commands] + restore_callbacks(route, :after) }) end end end result end |