method
scope
v3.0.0 -
Show latest stable
-
0 notes -
Class: ActionDispatch::Routing::Mapper::Scoping
- 1.0.0
- 1.1.6
- 1.2.6
- 2.0.3
- 2.1.0
- 2.2.1
- 2.3.8
- 3.0.0 (0)
- 3.0.9 (38)
- 3.1.0 (-18)
- 3.2.1 (0)
- 3.2.8 (0)
- 3.2.13 (0)
- 4.0.2 (-1)
- 4.1.8 (0)
- 4.2.1 (0)
- 4.2.7 (0)
- 4.2.9 (0)
- 5.0.0.1 (0)
- 5.1.7 (0)
- 5.2.3 (0)
- 6.0.0 (0)
- 6.1.3.1
- 6.1.7.7
- 7.0.0
- 7.1.3.2
- 7.1.3.4
- What's this?
scope(*args)
public
Hide source
# File actionpack/lib/action_dispatch/routing/mapper.rb, line 323 def scope(*args) options = args.extract_options! options = options.dup if name_prefix = options.delete(:name_prefix) options[:as] ||= name_prefix ActiveSupport::Deprecation.warn ":name_prefix was deprecated in the new router syntax. Use :as instead.", caller end options[:path] = args.first if args.first.is_a?(String) recover = {} options[:constraints] ||= {} unless options[:constraints].is_a?(Hash) block, options[:constraints] = options[:constraints], {} end scope_options.each do |option| if value = options.delete(option) recover[option] = @scope[option] @scope[option] = send("merge_#{option}_scope", @scope[option], value) end end recover[:block] = @scope[:blocks] @scope[:blocks] = merge_blocks_scope(@scope[:blocks], block) recover[:options] = @scope[:options] @scope[:options] = merge_options_scope(@scope[:options], options) yield self ensure scope_options.each do |option| @scope[option] = recover[option] if recover.has_key?(option) end @scope[:options] = recover[:options] @scope[:blocks] = recover[:block] end