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
 - #null? ⇒ Boolean
 - #options ⇒ Object
 - #resource_method_scope? ⇒ Boolean
 - #resource_scope? ⇒ Boolean
 - #resources? ⇒ Boolean
 - #root? ⇒ Boolean
 
Constructor Details
Instance Attribute Details
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
      2233 2234 2235  | 
    
      # File 'lib/action_dispatch/routing/mapper.rb', line 2233 def parent @parent end  | 
  
#scope_level ⇒ Object (readonly)
Returns the value of attribute scope_level.
      2233 2234 2235  | 
    
      # File 'lib/action_dispatch/routing/mapper.rb', line 2233 def scope_level @scope_level end  | 
  
Instance Method Details
#[](key) ⇒ Object
      2294 2295 2296 2297  | 
    
      # File 'lib/action_dispatch/routing/mapper.rb', line 2294 def [](key) scope = find { |node| node.frame.key? key } scope && scope.frame[key] end  | 
  
#action_name(name_prefix, prefix, collection_name, member_name) ⇒ Object
      2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276  | 
    
      # File 'lib/action_dispatch/routing/mapper.rb', line 2261 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
      2301 2302 2303 2304 2305 2306 2307  | 
    
      # File 'lib/action_dispatch/routing/mapper.rb', line 2301 def each node = self until node.equal? NULL yield node node = node.parent end end  | 
  
#frame ⇒ Object
      2309  | 
    
      # File 'lib/action_dispatch/routing/mapper.rb', line 2309 def frame; @hash; end  | 
  
#nested? ⇒ Boolean
      2241 2242 2243  | 
    
      # File 'lib/action_dispatch/routing/mapper.rb', line 2241 def nested? scope_level == :nested end  | 
  
#new(hash) ⇒ Object
      2286 2287 2288  | 
    
      # File 'lib/action_dispatch/routing/mapper.rb', line 2286 def new(hash) self.class.new hash, self, scope_level end  | 
  
#new_level(level) ⇒ Object
      2290 2291 2292  | 
    
      # File 'lib/action_dispatch/routing/mapper.rb', line 2290 def new_level(level) self.class.new(frame, self, level) end  | 
  
#null? ⇒ Boolean
      2245 2246 2247  | 
    
      # File 'lib/action_dispatch/routing/mapper.rb', line 2245 def null? @hash.nil? && @parent.nil? end  | 
  
#options ⇒ Object
      2282 2283 2284  | 
    
      # File 'lib/action_dispatch/routing/mapper.rb', line 2282 def OPTIONS end  | 
  
#resource_method_scope? ⇒ Boolean
      2257 2258 2259  | 
    
      # File 'lib/action_dispatch/routing/mapper.rb', line 2257 def resource_method_scope? RESOURCE_METHOD_SCOPES.include? scope_level end  | 
  
#resource_scope? ⇒ Boolean
      2278 2279 2280  | 
    
      # File 'lib/action_dispatch/routing/mapper.rb', line 2278 def resource_scope? RESOURCE_SCOPES.include? scope_level end  | 
  
#resources? ⇒ Boolean
      2253 2254 2255  | 
    
      # File 'lib/action_dispatch/routing/mapper.rb', line 2253 def resources? scope_level == :resources end  | 
  
#root? ⇒ Boolean
      2249 2250 2251  | 
    
      # File 'lib/action_dispatch/routing/mapper.rb', line 2249 def root? @parent.null? end  |