Sha256: 5617b7c30896567d2ba01de11270f8a5bf8298e9b83005dcfcbef0b2645b8264

Contents?: true

Size: 1.67 KB

Versions: 27

Compression:

Stored size: 1.67 KB

Contents

module ActionDispatch
  module Routing
    class RouteSet #:nodoc:
      def add_route(app, conditions = {}, requirements = {}, defaults = {}, name = nil, anchor = true)
        raise ArgumentError, "Invalid route name: '#{name}'" unless name.blank? || name.to_s.match(/^[_a-z]\w*$/i)

        forbidden_paths = [
          ::File.join(Gem.loaded_specs['scrivito_sdk'].full_name, "config/routes.rb"),
          ::File.join(Gem.loaded_specs['scrivito_sdk'].full_name, "config/precedence_routes.rb"),
          ::File.join(Gem.loaded_specs['infopark_fiona_connector'].full_name, "config/cms_routes.rb")
        ]

        if caller.any? {|path| forbidden_paths.any? {|fp| path.include?(fp) } }
          return  # bad dog scrivito/fiona_connector, bad dog! no cms_routes for you
        end

        if name && named_routes[name]
          raise ArgumentError, "Invalid route name, already in use: '#{name}' \n" \
            "You may have defined two routes with the same name using the `:as` option, or " \
            "you may be overriding a route already defined by a resource with the same naming. " \
            "For the latter, you can restrict the routes created with `resources` as explained here: \n" \
            "http://guides.rubyonrails.org/routing.html#restricting-the-routes-created"
        end

        path = conditions.delete :path_info
        ast  = conditions.delete :parsed_path_info
        path = build_path(path, ast, requirements, anchor)
        conditions = build_conditions(conditions, path.names.map { |x| x.to_sym })

        route = @set.add_route(app, path, conditions, defaults, name)
        named_routes[name] = route if name
        route
      end

    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
infopark_fiona7-1.2.0.0.0 lib/fiona7/routing_monkey_patch.rb
infopark_fiona7-1.1.0.0.9 lib/fiona7/routing_monkey_patch.rb
infopark_fiona7-1.1.0.0.8 lib/fiona7/routing_monkey_patch.rb
infopark_fiona7-1.1.0.0.7 lib/fiona7/routing_monkey_patch.rb
infopark_fiona7-1.1.0.0.6 lib/fiona7/routing_monkey_patch.rb
infopark_fiona7-1.1.0.0.5 lib/fiona7/routing_monkey_patch.rb
infopark_fiona7-1.1.0.0.10 lib/fiona7/routing_monkey_patch.rb