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 definition defines cells.

Returns:

  • (Boolean)


27
28
29
# File 'app/models/alchemy/page/page_cells.rb', line 27

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

#cell_definitionsObject

Returns the cell definitions from page definition.



37
38
39
40
41
# File 'app/models/alchemy/page/page_cells.rb', line 37

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.



49
50
51
# File 'app/models/alchemy/page/page_cells.rb', line 49

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.



54
55
56
# File 'app/models/alchemy/page/page_cells.rb', line 54

def element_names_not_in_cell
  definition['elements'].uniq - element_names_from_cells
end

#elements_grouped_by_cellsObject

Returns elements grouped by cell.



44
45
46
# File 'app/models/alchemy/page/page_cells.rb', line 44

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)


32
33
34
# File 'app/models/alchemy/page/page_cells.rb', line 32

def has_cells?
  cells.any?
end