aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2015-08-14 14:41:48 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2015-08-14 14:41:48 -0700
commit5ba6966766e67af4ae0028c4429acbd280a100a2 (patch)
tree2d7234541441879bc441a6cc046c1498ab20a203 /actionpack/lib/action_dispatch
parent68dd5abf1459e22ca64295ca3b4d6bcf2a525849 (diff)
downloadrails-5ba6966766e67af4ae0028c4429acbd280a100a2.tar.gz
rails-5ba6966766e67af4ae0028c4429acbd280a100a2.tar.bz2
rails-5ba6966766e67af4ae0028c4429acbd280a100a2.zip
pass the mapping object to build_route
now that we aren't doing options manipulations, we can just pass the mapping object down and read values from it.
Diffstat (limited to 'actionpack/lib/action_dispatch')
-rw-r--r--actionpack/lib/action_dispatch/routing/mapper.rb10
-rw-r--r--actionpack/lib/action_dispatch/routing/route_set.rb10
2 files changed, 10 insertions, 10 deletions
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb
index 093c5a1b04..70adb42df5 100644
--- a/actionpack/lib/action_dispatch/routing/mapper.rb
+++ b/actionpack/lib/action_dispatch/routing/mapper.rb
@@ -61,6 +61,7 @@ module ActionDispatch
attr_reader :requirements, :conditions, :defaults
attr_reader :to, :default_controller, :default_action
+ attr_reader :required_defaults
def self.build(scope, set, ast, controller, default_action, to, via, formatted, options_constraints, options)
options = scope[:options].merge(options) if scope[:options]
@@ -136,14 +137,14 @@ module ActionDispatch
@conditions = Hash[conditions]
@defaults = formats[:defaults].merge(@defaults).merge(normalize_defaults(options))
- @conditions[:required_defaults] = (split_options[:required_defaults] || []).map(&:first)
+ @required_defaults = (split_options[:required_defaults] || []).map(&:first)
unless via == [:all]
@conditions[:request_method] = via.map { |m| m.to_s.dasherize.upcase }
end
end
- def to_route
- [ app(@blocks), conditions, requirements, defaults ]
+ def application
+ app(@blocks)
end
private
@@ -1619,8 +1620,7 @@ to this:
ast = Journey::Parser.parse path
mapping = Mapping.build(@scope, @set, ast, controller, default_action, to, via, formatted, options_constraints, options)
- app, conditions, requirements, defaults = mapping.to_route
- @set.add_route(app, conditions, ast, requirements, defaults, as, anchor)
+ @set.add_route(mapping, ast, as, anchor)
end
def root(path, options={})
diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb
index 04d8013768..df3b2bbc25 100644
--- a/actionpack/lib/action_dispatch/routing/route_set.rb
+++ b/actionpack/lib/action_dispatch/routing/route_set.rb
@@ -514,7 +514,7 @@ module ActionDispatch
routes.empty?
end
- def add_route(app, conditions, path_ast, requirements, defaults, name, anchor)
+ def add_route(mapping, path_ast, name, anchor)
raise ArgumentError, "Invalid route name: '#{name}'" unless name.blank? || name.to_s.match(/^[_a-z]\w*$/i)
if name && named_routes[name]
@@ -525,11 +525,11 @@ module ActionDispatch
"http://guides.rubyonrails.org/routing.html#restricting-the-routes-created"
end
- required_defaults = conditions.delete :required_defaults
- path = build_path(path_ast, requirements, anchor)
- conditions = build_conditions(conditions)
+ required_defaults = mapping.required_defaults
+ path = build_path(path_ast, mapping.requirements, anchor)
+ conditions = build_conditions(mapping.conditions)
- route = @set.add_route(app, path, conditions, required_defaults, defaults, name)
+ route = @set.add_route(mapping.application, path, conditions, required_defaults, mapping.defaults, name)
named_routes[name] = route if name
route
end