diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2014-05-30 11:29:37 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2014-06-03 11:33:51 -0700 |
commit | e975b7d04e6497e3d3c8c23a174b79968a28efb7 (patch) | |
tree | 9e73cd1fa8d325a420b50085d1d0438a082ed722 /actionpack/lib/action_dispatch/routing | |
parent | 4bc441c6f87c06426017a914347f0076bc70cbb5 (diff) | |
download | rails-e975b7d04e6497e3d3c8c23a174b79968a28efb7.tar.gz rails-e975b7d04e6497e3d3c8c23a174b79968a28efb7.tar.bz2 rails-e975b7d04e6497e3d3c8c23a174b79968a28efb7.zip |
disconnect the constraints method from the options and scope hashes
Diffstat (limited to 'actionpack/lib/action_dispatch/routing')
-rw-r--r-- | actionpack/lib/action_dispatch/routing/mapper.rb | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index 8d52eb0d11..1b944fb308 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -84,9 +84,12 @@ module ActionDispatch ast = path_ast path path_params = path_params ast @options = normalize_options!(options, formatted, path_params, ast) - normalize_requirements!(path_params, formatted) - normalize_conditions!(path_params, path, ast, via) + + constraints = constraints(options[:constraints], scope[:constraints]) + normalize_requirements!(path_params, formatted, constraints) + + normalize_conditions!(path_params, path, ast, via, constraints) normalize_defaults!(formatted) end @@ -138,7 +141,7 @@ module ActionDispatch end end - def normalize_requirements!(path_params, formatted) + def normalize_requirements!(path_params, formatted, constraints) constraints.each do |key, requirement| next unless path_params.include?(key) || key == :controller verify_regexp_requirement(requirement) if requirement.is_a?(Regexp) @@ -197,7 +200,7 @@ module ActionDispatch end end - def normalize_conditions!(path_params, path, ast, via) + def normalize_conditions!(path_params, path, ast, via, constraints) @conditions[:path_info] = path @conditions[:parsed_path_info] = ast @@ -308,16 +311,16 @@ module ActionDispatch end end - def constraints - @constraints ||= {}.tap do |constraints| - constraints.merge!(scope[:constraints]) if scope[:constraints] + def constraints(option_constraints, scope_constraints) + constraints = {} + constraints.merge!(scope_constraints) if scope_constraints - options.except(*IGNORE_OPTIONS).each do |key, option| - constraints[key] = option if Regexp === option - end - - constraints.merge!(options[:constraints]) if options[:constraints].is_a?(Hash) + options.except(*IGNORE_OPTIONS).each do |key, option| + constraints[key] = option if Regexp === option end + + constraints.merge!(option_constraints) if option_constraints.is_a?(Hash) + constraints end def path_params(ast) |