app/models/alchemy/element.rb
# This methods does a copy of source and all depending contents and all of their depending essences.
#
# == Options
#
# You can pass a differences Hash as second option to update attributes for the copy.
#
# == Example
#
#   @copy = Alchemy::Element.copy(@element, {public: false})
#   @copy.public? # => false
#
This methods does a copy of source and all depending contents and all of their depending essences.
Options

You can pass a differences Hash as second option to update attributes for the copy.

Example


This methods does a copy of source and all depending contents and all of their depending essences . Options You can pass a differences Hash as second option to update attributes for the copy . Example
def copy(source_element, differences = {})
        attributes = source_element.attributes.with_indifferent_access
          .except(*SKIPPED_ATTRIBUTES_ON_COPY)
          .merge(differences)
          .merge({
            autogenerate_contents: false,
            autogenerate_nested_elements: false,
            tag_list: source_element.tag_list,
          })
        new_element = create!(attributes)
        if source_element.contents.any?
          source_element.copy_contents_to(new_element)
        end
        if source_element.nested_elements.any?
          source_element.copy_nested_elements_to(new_element)
        end
        new_element
      end
def copy ( source_element , differences = { } ) attributes = source_element . attributes . with_indifferent_access . except ( * SKIPPED_ATTRIBUTES_ON_COPY ) . merge ( differences ) . merge ( { autogenerate_contents : false , autogenerate_nested_elements : false , tag_list : source_element . tag_list , } ) new_element = create! ( attributes ) if source_element . contents . any? source_element . copy_contents_to ( new_element ) end if source_element . nested_elements . any? source_element . copy_nested_elements_to ( new_element ) end new_element end
This methods does a copy of source and all depending contents and all of their depending essences.
This methods does a copy of source and all depending contents and all of their depending essences .
source_element
differences