Class: Alchemy::PageLayout
- Inherits:
 - 
      Object
      
        
- Object
 - Alchemy::PageLayout
 
 
- Defined in:
 - lib/alchemy/page_layout.rb
 
Class Method Summary collapse
- 
  
    
      .add(page_layout)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Add additional page definitions to collection.
 - 
  
    
      .all  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Returns all page layouts.
 - 
  
    
      .get(name)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Returns one page definition by given name.
 - 
  
    
      .layouts_file_path  ⇒ Pathname 
    
    
  
  
  
  
  
  
  
  
  
    
The absolute
page_layouts.ymlfile path. - .reset! ⇒ Object
 
Class Method Details
.add(page_layout) ⇒ Object
Add additional page definitions to collection.
Useful for extending the page layouts from an Alchemy module.
Usage Example
Call +Alchemy::PageLayout.add(your_definition)+ in your engine.rb file.
  
      25 26 27 28 29 30 31 32 33 34  | 
    
      # File 'lib/alchemy/page_layout.rb', line 25 def add(page_layout) all if page_layout.is_a?(Array) @definitions += page_layout elsif page_layout.is_a?(Hash) @definitions << page_layout else raise TypeError end end  | 
  
.all ⇒ Object
Returns all page layouts.
They are defined in config/alchemy/page_layout.yml file.
      10 11 12  | 
    
      # File 'lib/alchemy/page_layout.rb', line 10 def all @definitions ||= read_definitions_file.map(&:with_indifferent_access) end  | 
  
.get(name) ⇒ Object
Returns one page definition by given name.
      38 39 40 41 42  | 
    
      # File 'lib/alchemy/page_layout.rb', line 38 def get(name) return {} if name.blank? all.detect { |a| a["name"].casecmp(name).zero? } end  | 
  
.layouts_file_path ⇒ Pathname
The absolute page_layouts.yml file path
      50 51 52  | 
    
      # File 'lib/alchemy/page_layout.rb', line 50 def layouts_file_path Rails.root.join("config", "alchemy", "page_layouts.yml") end  | 
  
.reset! ⇒ Object
      44 45 46  | 
    
      # File 'lib/alchemy/page_layout.rb', line 44 def reset! @definitions = nil end  |