Class: Alchemy::PageDefinition
- Inherits:
-
Object
- Object
- Alchemy::PageDefinition
- Extended by:
- ActiveModel::Translation
- Includes:
- ActiveModel::Attributes, ActiveModel::Model, Hints
- Defined in:
- app/models/alchemy/page_definition.rb
Class Method Summary collapse
-
.add(definition) ⇒ 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.yml
file path. - .map ⇒ Object (also: collect)
- .reset! ⇒ Object
Instance Method Summary collapse
Methods included from Hints
Class Method Details
.add(definition) ⇒ Object
Add additional page definitions to collection.
Useful for extending the page layouts from an Alchemy module.
Usage Example
Call +Alchemy::PageDefinition.add(your_definition)+ in your engine.rb file.
59 60 61 62 |
# File 'app/models/alchemy/page_definition.rb', line 59 def add(definition) all @definitions += Array.wrap(definition).map { new(**_1) } end |
.all ⇒ Object
Returns all page layouts.
They are defined in config/alchemy/page_layout.yml
file.
39 40 41 |
# File 'app/models/alchemy/page_definition.rb', line 39 def all @definitions ||= read_definitions_file.map { new(**_1) } end |
.get(name) ⇒ Object
Returns one page definition by given name.
66 67 68 69 70 |
# File 'app/models/alchemy/page_definition.rb', line 66 def get(name) return new if name.blank? all.detect { _1.name.casecmp(name).zero? } end |
.layouts_file_path ⇒ Pathname
The absolute page_layouts.yml
file path
78 79 80 |
# File 'app/models/alchemy/page_definition.rb', line 78 def layouts_file_path Rails.root.join("config", "alchemy", "page_layouts.yml") end |
.map ⇒ Object Also known as: collect
43 44 45 |
# File 'app/models/alchemy/page_definition.rb', line 43 def map(...) all.map(...) end |
.reset! ⇒ Object
72 73 74 |
# File 'app/models/alchemy/page_definition.rb', line 72 def reset! @definitions = nil end |
Instance Method Details
#attributes ⇒ Object
105 106 107 |
# File 'app/models/alchemy/page_definition.rb', line 105 def attributes super.with_indifferent_access end |