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

Methods inherited from ApplicationRecord

available_statuses

Instance Method Details

#dupList

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

Returns:

  • (List)

    Unsaved cloned list



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

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