Method: ActionDispatch::Routing::Mapper::Mapping#initialize
- Defined in:
- actionpack/lib/action_dispatch/routing/mapper.rb
#initialize(set:, ast:, controller:, default_action:, to:, formatted:, via:, options_constraints:, anchor:, scope_params:, options:) ⇒ Mapping
Returns a new instance of Mapping.
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 132 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) @anchor = anchor @via = via @internal = .delete(:internal) = scope_params[:options] ast = Journey::Ast.new(ast, formatted) = ast..merge!() = (, ast.path_params, scope_params[:module]) = constraints(, ast.path_params) constraints = scope_params[:constraints].merge Hash[[:constraints] || []] if .is_a?(Hash) @defaults = Hash[.find_all { |key, default| URL_OPTIONS.include?(key) && (String === default || Integer === default) }].merge @defaults @blocks = scope_params[:blocks] constraints.merge! else @blocks = blocks() end requirements, conditions = split_constraints ast.path_params, constraints verify_regexp_requirements requirements, ast. formats = normalize_format(formatted) @requirements = formats[:requirements].merge Hash[requirements] @conditions = Hash[conditions] @defaults = formats[:defaults].merge(@defaults).merge(normalize_defaults()) if ast.path_params.include?(:action) && !@requirements.key?(:action) @defaults[:action] ||= "index" end @required_defaults = ([:required_defaults] || []).map(&:first) ast.requirements = @requirements @path = Journey::Path::Pattern.new(ast, @requirements, JOINED_SEPARATORS, @anchor) end |