Module: Alchemy::Page::PageElements::ClassMethods

Defined in:
app/models/alchemy/page/page_elements.rb

Instance Method Summary collapse

Instance Method Details

#copy_elements(source, target) ⇒ Array

Copy page elements

Parameters:

Returns:

  • (Array)


38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'app/models/alchemy/page/page_elements.rb', line 38

def copy_elements(source, target)
  repository = source.draft_version.element_repository
  transaction do
    Element.acts_as_list_no_update do
      repository.not_nested.each.with_index(1) do |element, position|
        Alchemy::DuplicateElement.new(element, repository: repository).call(
          page_version_id: target.draft_version.id,
          position: position
        )
      end
    end
  end
end