aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2015-08-12 14:30:40 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2015-08-12 14:30:54 -0700
commit1c9431753939b9987416debf839d5707efe4dc18 (patch)
tree64a21485e62738455c5af477a58b2b536c2b7dc9 /actionpack/lib/action_dispatch
parent58117fadae1ccc1d84672cbecdc965727245e0fe (diff)
downloadrails-1c9431753939b9987416debf839d5707efe4dc18.tar.gz
rails-1c9431753939b9987416debf839d5707efe4dc18.tar.bz2
rails-1c9431753939b9987416debf839d5707efe4dc18.zip
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.
Diffstat (limited to 'actionpack/lib/action_dispatch')
-rw-r--r--actionpack/lib/action_dispatch/routing/mapper.rb10
1 files changed, 8 insertions, 2 deletions
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