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

Instance Method Details

#can_have_cells?Boolean

Returns true, if the page’s page_layout defines cells.

Returns:

  • (Boolean)


30
31
32
# File 'app/models/alchemy/page/page_cells.rb', line 30

def can_have_cells?
  definition['cells'].present?
end

#cell_definitionsObject

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_cellsObject

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_cellObject

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_cellsObject

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.

Returns:

  • (Boolean)


35
36
37
# File 'app/models/alchemy/page/page_cells.rb', line 35

def has_cells?
  cells.any?
end