From 29506d0f03a76b09497d1a392ef1adbddf776102 Mon Sep 17 00:00:00 2001 From: Alberto Almagro Date: Tue, 11 Dec 2018 23:45:57 +0100 Subject: Use keyword arguments for ActionDispatch::Journey:Route constructor This commit changes from constructor's argument list to keyword arguments in order to remove the dependency of remember parameters' positions. The constructor already provided a default value for `internal`, this commits takes the chance to also add default values for `precedence` and `scope_options`. --- actionpack/lib/action_dispatch/journey/route.rb | 7 ++++--- actionpack/lib/action_dispatch/routing/mapper.rb | 6 ++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/actionpack/lib/action_dispatch/journey/route.rb b/actionpack/lib/action_dispatch/journey/route.rb index 587ebcb873..d497b9d475 100644 --- a/actionpack/lib/action_dispatch/journey/route.rb +++ b/actionpack/lib/action_dispatch/journey/route.rb @@ -50,14 +50,15 @@ module ActionDispatch end def self.build(name, app, path, constraints, required_defaults, defaults) - request_method_match = verb_matcher(constraints.delete(:request_method)) - new name, app, path, constraints, required_defaults, defaults, request_method_match, 0, {} + new name: name, app: app, path: path, constraints: constraints, + required_defaults: required_defaults, defaults: defaults, + request_method_match: verb_matcher(constraints.delete(:request_method)) end ## # +path+ is a path constraint. # +constraints+ is a hash of constraints to be applied to this route. - def initialize(name, app, path, constraints, required_defaults, defaults, request_method_match, precedence, scope_options, internal = false) + def initialize(name:, app:, path:, constraints:, required_defaults:, defaults:, request_method_match:, precedence: 0, scope_options: {}, internal: false) @name = name @app = app @path = path diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index 695eed3adc..6000524796 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -161,8 +161,10 @@ module ActionDispatch end def make_route(name, precedence) - Journey::Route.new(name, application, path, conditions, required_defaults, - defaults, request_method, precedence, scope_options, @internal) + Journey::Route.new(name: name, app: application, path: path, constraints: conditions, + required_defaults: required_defaults, defaults: defaults, + request_method_match: request_method, precedence: precedence, + scope_options: scope_options, internal: @internal) end def application -- cgit v1.2.3