Class: ActionDispatch::Routing::Mapper::Scope
- Inherits:
-
Object
- Object
- ActionDispatch::Routing::Mapper::Scope
- Includes:
- Enumerable
- Defined in:
- lib/action_dispatch/routing/mapper.rb
Overview
:nodoc:
Constant Summary collapse
- OPTIONS =
[:path, :shallow_path, :as, :shallow_prefix, :module, :controller, :action, :path_names, :constraints, :shallow, :blocks, :defaults, :via, :format, :options, :to]
- RESOURCE_SCOPES =
[:resource, :resources]
- RESOURCE_METHOD_SCOPES =
[:collection, :member, :new]
- NULL =
Scope.new(nil, nil)
Instance Attribute Summary collapse
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
-
#scope_level ⇒ Object
readonly
Returns the value of attribute scope_level.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #action_name(name_prefix, prefix, collection_name, member_name) ⇒ Object
- #each ⇒ Object
- #frame ⇒ Object
-
#initialize(hash, parent = NULL, scope_level = nil) ⇒ Scope
constructor
A new instance of Scope.
- #nested? ⇒ Boolean
- #new(hash) ⇒ Object
- #new_level(level) ⇒ Object
- #options ⇒ Object
- #resource_method_scope? ⇒ Boolean
- #resource_scope? ⇒ Boolean
- #resources? ⇒ Boolean
Constructor Details
Instance Attribute Details
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
2059 2060 2061 |
# File 'lib/action_dispatch/routing/mapper.rb', line 2059 def parent @parent end |
#scope_level ⇒ Object (readonly)
Returns the value of attribute scope_level.
2059 2060 2061 |
# File 'lib/action_dispatch/routing/mapper.rb', line 2059 def scope_level @scope_level end |
Instance Method Details
#[](key) ⇒ Object
2112 2113 2114 2115 |
# File 'lib/action_dispatch/routing/mapper.rb', line 2112 def [](key) scope = find { |node| node.frame.key? key } scope && scope.frame[key] end |
#action_name(name_prefix, prefix, collection_name, member_name) ⇒ Object
2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 |
# File 'lib/action_dispatch/routing/mapper.rb', line 2079 def action_name(name_prefix, prefix, collection_name, member_name) case scope_level when :nested [name_prefix, prefix] when :collection [prefix, name_prefix, collection_name] when :new [prefix, :new, name_prefix, member_name] when :member [prefix, name_prefix, member_name] when :root [name_prefix, collection_name, prefix] else [name_prefix, member_name, prefix] end end |
#each ⇒ Object
2119 2120 2121 2122 2123 2124 2125 2126 |
# File 'lib/action_dispatch/routing/mapper.rb', line 2119 def each node = self loop do break if node.equal? NULL yield node node = node.parent end end |
#frame ⇒ Object
2128 |
# File 'lib/action_dispatch/routing/mapper.rb', line 2128 def frame; @hash; end |
#nested? ⇒ Boolean
2067 2068 2069 |
# File 'lib/action_dispatch/routing/mapper.rb', line 2067 def nested? scope_level == :nested end |
#new(hash) ⇒ Object
2104 2105 2106 |
# File 'lib/action_dispatch/routing/mapper.rb', line 2104 def new(hash) self.class.new hash, self, scope_level end |
#new_level(level) ⇒ Object
2108 2109 2110 |
# File 'lib/action_dispatch/routing/mapper.rb', line 2108 def new_level(level) self.class.new(frame, self, level) end |
#options ⇒ Object
2100 2101 2102 |
# File 'lib/action_dispatch/routing/mapper.rb', line 2100 def OPTIONS end |
#resource_method_scope? ⇒ Boolean
2075 2076 2077 |
# File 'lib/action_dispatch/routing/mapper.rb', line 2075 def resource_method_scope? RESOURCE_METHOD_SCOPES.include? scope_level end |
#resource_scope? ⇒ Boolean
2096 2097 2098 |
# File 'lib/action_dispatch/routing/mapper.rb', line 2096 def resource_scope? RESOURCE_SCOPES.include? scope_level end |
#resources? ⇒ Boolean
2071 2072 2073 |
# File 'lib/action_dispatch/routing/mapper.rb', line 2071 def resources? scope_level == :resources end |