Module: Alchemy::Page::PageCells
- Extended by:
- ActiveSupport::Concern
- Included in:
- Alchemy::Page
- Defined in:
- app/models/alchemy/page/page_cells.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
-
#can_have_cells? ⇒ Boolean
Returns true, if the page’s page_layout defines cells.
-
#cell_definitions ⇒ Object
Returns the cell definitions from page definition.
-
#element_names_from_cells ⇒ Object
Returns element names from cell definition.
-
#element_names_not_in_cell ⇒ Object
Returns element names that are not defined in a cell.
-
#elements_grouped_by_cells ⇒ Object
Returns elements grouped by cell.
-
#has_cells? ⇒ Boolean
Returns true, if the page has cells.
Instance Method Details
#can_have_cells? ⇒ Boolean
Returns true, if the page’s page_layout defines cells.
30 31 32 |
# File 'app/models/alchemy/page/page_cells.rb', line 30 def can_have_cells? definition['cells'].present? end |
#cell_definitions ⇒ Object
Returns the cell definitions from page definition.
40 41 42 43 44 |
# File 'app/models/alchemy/page/page_cells.rb', line 40 def cell_definitions cell_names = definition['cells'] return [] if cell_names.blank? Cell.all_definitions_for(cell_names) end |
#element_names_from_cells ⇒ Object
Returns element names from cell definition.
52 53 54 |
# File 'app/models/alchemy/page/page_cells.rb', line 52 def element_names_from_cells cell_definitions.collect { |c| c['elements'] }.flatten.uniq end |
#element_names_not_in_cell ⇒ Object
Returns element names that are not defined in a cell.
57 58 59 |
# File 'app/models/alchemy/page/page_cells.rb', line 57 def element_names_not_in_cell layout_description['elements'].uniq - element_names_from_cells end |
#elements_grouped_by_cells ⇒ Object
Returns elements grouped by cell.
47 48 49 |
# File 'app/models/alchemy/page/page_cells.rb', line 47 def elements_grouped_by_cells elements.not_trashed.in_cell.group_by(&:cell) end |
#has_cells? ⇒ Boolean
Returns true, if the page has cells.
35 36 37 |
# File 'app/models/alchemy/page/page_cells.rb', line 35 def has_cells? cells.any? end |