Class: ActiveAdmin::ResourceCollection
- Inherits:
 - 
      Object
      
        
- Object
 - ActiveAdmin::ResourceCollection
 
 
- Extended by:
 - Forwardable
 
- Includes:
 - Enumerable
 
- Defined in:
 - lib/active_admin/resource_collection.rb
 
Overview
This is a container for resources, which acts much like a Hash. It’s assumed that an added resource responds to ‘resource_name`.
Defined Under Namespace
Classes: ConfigMismatch, IncorrectClass
Instance Method Summary collapse
- #[](obj) ⇒ Object
 - #add(resource) ⇒ Object
 - 
  
    
      #each(&block)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Changes ‘each` to pass in the value, instead of both the key and value.
 - 
  
    
      #initialize  ⇒ ResourceCollection 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of ResourceCollection.
 
Constructor Details
#initialize ⇒ ResourceCollection
Returns a new instance of ResourceCollection.
      10 11 12  | 
    
      # File 'lib/active_admin/resource_collection.rb', line 10 def initialize @collection = {} end  | 
  
Instance Method Details
#[](obj) ⇒ Object
      28 29 30  | 
    
      # File 'lib/active_admin/resource_collection.rb', line 28 def [](obj) @collection[obj] || find_resource(obj) end  | 
  
#add(resource) ⇒ Object
      14 15 16 17 18 19 20 21  | 
    
      # File 'lib/active_admin/resource_collection.rb', line 14 def add(resource) if match = @collection[resource.resource_name] raise_if_mismatched! match, resource match else @collection[resource.resource_name] = resource end end  | 
  
#each(&block) ⇒ Object
Changes ‘each` to pass in the value, instead of both the key and value.
      24 25 26  | 
    
      # File 'lib/active_admin/resource_collection.rb', line 24 def each(&block) values.each &block end  |