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.
2046 2047 2048 |
# File 'lib/action_dispatch/routing/mapper.rb', line 2046 def parent @parent end |
#scope_level ⇒ Object (readonly)
Returns the value of attribute scope_level.
2046 2047 2048 |
# File 'lib/action_dispatch/routing/mapper.rb', line 2046 def scope_level @scope_level end |
Instance Method Details
#[](key) ⇒ Object
2099 2100 2101 2102 |
# File 'lib/action_dispatch/routing/mapper.rb', line 2099 def [](key) scope = find { |node| node.frame.key? key } scope && scope.frame[key] end |
#action_name(name_prefix, prefix, collection_name, member_name) ⇒ Object
2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 |
# File 'lib/action_dispatch/routing/mapper.rb', line 2066 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
2106 2107 2108 2109 2110 2111 2112 2113 |
# File 'lib/action_dispatch/routing/mapper.rb', line 2106 def each node = self loop do break if node.equal? NULL yield node node = node.parent end end |
#frame ⇒ Object
2115 |
# File 'lib/action_dispatch/routing/mapper.rb', line 2115 def frame; @hash; end |
#nested? ⇒ Boolean
2054 2055 2056 |
# File 'lib/action_dispatch/routing/mapper.rb', line 2054 def nested? scope_level == :nested end |
#new(hash) ⇒ Object
2091 2092 2093 |
# File 'lib/action_dispatch/routing/mapper.rb', line 2091 def new(hash) self.class.new hash, self, scope_level end |
#new_level(level) ⇒ Object
2095 2096 2097 |
# File 'lib/action_dispatch/routing/mapper.rb', line 2095 def new_level(level) self.class.new(frame, self, level) end |
#options ⇒ Object
2087 2088 2089 |
# File 'lib/action_dispatch/routing/mapper.rb', line 2087 def OPTIONS end |
#resource_method_scope? ⇒ Boolean
2062 2063 2064 |
# File 'lib/action_dispatch/routing/mapper.rb', line 2062 def resource_method_scope? RESOURCE_METHOD_SCOPES.include? scope_level end |
#resource_scope? ⇒ Boolean
2083 2084 2085 |
# File 'lib/action_dispatch/routing/mapper.rb', line 2083 def resource_scope? RESOURCE_SCOPES.include? scope_level end |
#resources? ⇒ Boolean
2058 2059 2060 |
# File 'lib/action_dispatch/routing/mapper.rb', line 2058 def resources? scope_level == :resources end |