module ActionDispatch
module Routing
class Mapper
def initialize(set)
@set = set
@scope = Scope.new({ :path_names => @set.resources_path_names })
@concerns = {}
@nesting = []
end
end
end
end
module ActionDispatch
module Routing
class Mapper
module Resources
# ...
def match
# ...
end
# ... ...
def add_route(action, options)
path = path_for_action(action, options.delete(:path))
# ... ...
as = if !options.fetch(:as, true)
options.delete(:as)
else
name_for_action(options.delete(:as), action)
end
mapping = Mapping.build(@scope, @set, URI.parser.escape(path), as, options)
app, conditions, requirements, defaults, as, anchor = mapping.to_route
@set.add_route(app, conditions, requirements, defaults, as, anchor)
end
end
end
end
end
module ActionDispatch
module Routing
class Mapper
class Mapping
def to_route
[ app(@blocks), conditions, requirements, defaults, as, anchor ]
end
private
def app(blocks)
if to.respond_to?(:call)
Constraints.new(to, blocks, false)
elsif blocks.any?
Constraints.new(dispatcher(defaults), blocks, true)
else
dispatcher(defaults)
end
end
end
end
end
end
Endpoint 的子类之一,它是 endpoint.