method
new
v6.1.7.7 -
Show latest stable
-
0 notes -
Class: ActionDispatch::Routing::Mapper::Mapping
- 1.0.0
- 1.1.6
- 1.2.6
- 2.0.3
- 2.1.0
- 2.2.1
- 2.3.8
- 3.0.0 (0)
- 3.0.9 (0)
- 3.1.0 (0)
- 3.2.1 (0)
- 3.2.8 (0)
- 3.2.13 (0)
- 4.0.2 (0)
- 4.1.8 (0)
- 4.2.1 (0)
- 4.2.7 (0)
- 4.2.9 (0)
- 5.0.0.1 (0)
- 5.1.7 (0)
- 5.2.3 (0)
- 6.0.0 (0)
- 6.1.3.1 (0)
- 6.1.7.7 (0)
- 7.0.0 (0)
- 7.1.3.2 (0)
- 7.1.3.4 (0)
- What's this?
new(set:, ast:, controller:, default_action:, to:, formatted:, via:, options_constraints:, anchor:, scope_params:, options:)
public
Hide source
# File actionpack/lib/action_dispatch/routing/mapper.rb, line 119 def initialize(set,, ast,, controller,, default_action,, to,, formatted,, via,, options_constraints,, anchor,, scope_params,, options)) @defaults = scope_params[:defaults] @set = set @to = intern(to) @default_controller = intern(controller) @default_action = intern(default_action) @ast = ast @anchor = anchor @via = via @internal = options.delete(:internal) @scope_options = scope_params[:options] path_params = [] wildcard_options = {} ast.each do |node| if node.symbol? path_params << node.to_sym elsif formatted != false && node.star? # Add a constraint for wildcard route to make it non-greedy and match the # optional format part of the route by default. wildcard_options[node.name.to_sym] ||= /.+?/ elsif node.cat? alter_regex_for_custom_routes(node) end end options = wildcard_options.merge!(options) options = normalize_options!(options, path_params, scope_params[:module]) split_options = constraints(options, path_params) constraints = scope_params[:constraints].merge Hash[split_options[:constraints] || []] if options_constraints.is_a?(Hash) @defaults = Hash[options_constraints.find_all { |key, default| URL_OPTIONS.include?(key) && (String === default || Integer === default) }].merge @defaults @blocks = scope_params[:blocks] constraints.merge! options_constraints else @blocks = blocks(options_constraints) end requirements, conditions = split_constraints path_params, constraints verify_regexp_requirements requirements.map(&:last).grep(Regexp) formats = normalize_format(formatted) @requirements = formats[:requirements].merge Hash[requirements] @conditions = Hash[conditions] @defaults = formats[:defaults].merge(@defaults).merge(normalize_defaults(options)) if path_params.include?(:action) && !@requirements.key?(:action) @defaults[:action] ||= "index" end @required_defaults = (split_options[:required_defaults] || []).map(&:first) end