Class: Integral::List
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Integral::List
- Defined in:
- app/models/integral/list.rb
Overview
Represents a generic list such as a gallery or menu
Instance Method Summary collapse
-
#dup(title = '') ⇒ List
Duplicates the list including all attributes, list items and list item children.
Instance Method Details
#dup(title = '') ⇒ List
Duplicates the list including all attributes, list items and list item children
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'app/models/integral/list.rb', line 33 def dup(title = '') new_list = super() new_list.title = title if title.present? 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 |