Class: Integral::List

Inherits:
ApplicationRecord show all
Defined in:
app/models/integral/list.rb

Overview

Represents a generic list such as a gallery or menu

Instance Method Summary collapse

Instance Method Details

#dupList

Duplicates the list including all attributes, list items and list item children

Returns:

  • (List)

    Unsaved cloned list



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'app/models/integral/list.rb', line 33

def dup
  new_list = super()

  list_items.each do |list_item|
    new_list_item = list_item.dup

    if list_item.has_children?
      list_item.children.each do |child|
        new_list_item.children << child.dup
      end
    end

    new_list.list_items << new_list_item
  end

  new_list
end