Module: Reactor::Legacy::Base
- Defined in:
- lib/reactor/legacy.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#delete_children!(options = {}) ⇒ Object
removes CMS objects underneath current object.
Class Method Details
.included(base) ⇒ Object
6 7 8 |
# File 'lib/reactor/legacy.rb', line 6 def self.included(base) base.extend(ClassMethods) end |
Instance Method Details
#delete_children!(options = {}) ⇒ Object
removes CMS objects underneath current object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/reactor/legacy.rb', line 14 def delete_children!(={}) # TODO: provide better discrimination mechanisms (blocks?) f_nochild = .delete(:no_children) f_imgchild = .delete(:img_children_only) f_children = .delete(:children) mychildren = self.children image_children, other_children = mychildren.partition {|obj| obj.obj_class == 'Image'} # are there any links pointing to this container return false if has_super_links? # is the flag set and are there any children return false if f_nochild && !mychildren.empty? # is the flag set and are there any children besides images return false if f_imgchild && !other_children.empty? # is the flag set and are there any children besides the specified ones return false if f_children && !((mychildren.map(&:name) - f_children).empty?) # check children for any links pointing to them return false if mychildren.detect(&:has_super_links?) # check if there are any grandchildren return false if mychildren.detect {|child| !child.children.empty?} # delete children mychildren.each(&:destroy) return true end |