instance method segment_tree

Ruby on Rails 2.2.3

Since v2.2.3 Last seen in v2.3.18

Available in: v2.2.3 v2.3.18

Signature

segment_tree(routes)

No documentation comment.

Parameters

routes req
Source
# File actionpack/lib/action_controller/routing/recognition_optimisation.rb, line 70
      def segment_tree(routes)
        tree = [0]

        i = -1
        routes.each do |route|
          i += 1
          # not fast, but runs only once
          segments = to_plain_segments(route.segments.inject("") { |str,s| str << s.to_s })

          node  = tree
          segments.each do |seg|
            seg = :dynamic if seg && seg[0] == ?:
            node << [seg, [i]] if node.empty? || node[node.size - 1][0] != seg
            node = node[node.size - 1][1]
          end
        end
        tree
      end

Defined in actionpack/lib/action_controller/routing/recognition_optimisation.rb line 70 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActionController::Routing::RouteSet

Type at least 2 characters to search.

↑↓ navigate · open · esc close