lib/reactor/legacy.rb in infopark_reactor-1.26.1 vs lib/reactor/legacy.rb in infopark_reactor-1.27.0.rc4
- old
+ new
@@ -1,6 +1,5 @@
-# -*- encoding : utf-8 -*-
module Reactor
# This is a collection of legacy method,s that have not found any better place to live.
module Legacy
module Base
def self.included(base)
@@ -9,35 +8,35 @@
# removes CMS objects underneath current object
# @option options :no_children if true prevents deletion unless there are no children
# @option options :img_children_only if true prevents deletion unless there are exclusively img children
# @option options [Array] :children if true prevents deletion if there are other children besides the specified ones (array of names)
- def delete_children!(options={})
+ def delete_children!(options = {})
# TODO: provide better discrimination mechanisms (blocks?)
f_nochild = options.delete(:no_children)
f_imgchild = options.delete(:img_children_only)
f_children = options.delete(:children)
- mychildren = self.children
- image_children, other_children = mychildren.partition {|obj| obj.obj_class == 'Image'}
+ mychildren = children
+ other_children = mychildren.reject { |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?)
+ 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?}
+ return false if mychildren.detect { |child| !child.children.empty? }
# delete children
mychildren.each(&:destroy)
- return true
+ true
end
end
module ClassMethods
def path_from_anything(anything)
obj_from_anything(anything).try(:path)