From 1c9431753939b9987416debf839d5707efe4dc18 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Wed, 12 Aug 2015 14:30:40 -0700 Subject: add a method to `Scope` for getting mapping options Eventually we don't want to expose the "options" hash from scope, only read values from it. Lets start by adding a reader method. --- actionpack/lib/action_dispatch/routing/mapper.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'actionpack/lib/action_dispatch') diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index bf35a2b960..6e1db3b492 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -62,7 +62,7 @@ module ActionDispatch attr_reader :to, :default_controller, :default_action, :as, :anchor def self.build(scope, set, path, as, controller, default_action, to, via, options) - formatted = options.delete(:format) { scope[:options] && scope[:options][:format] } + formatted = options.delete(:format) { scope.mapping_option(:format) } options = scope[:options].merge(options) if scope[:options] @@ -1543,7 +1543,7 @@ module ActionDispatch option_path = options.delete :path to = options.delete :to via = Mapping.check_via Array(options.delete(:via) { - (@scope[:options] || {})[:via] + @scope.mapping_option(:via) }) path_types = paths.group_by(&:class) @@ -1990,6 +1990,12 @@ module ActionDispatch OPTIONS end + def mapping_option(name) + options = self[:options] + return unless options + options[name] + end + def new(hash) self.class.new hash, self, scope_level end -- cgit v1.2.3