module Customize::Inherited::ClassMethods

Public Instance Methods

root() click to toggle source
# File lib/customize/inherited.rb, line 45
def root
        joins(:inherit_node).where("parent_id is null")
end
type_tree(node = nil) click to toggle source
# File lib/customize/inherited.rb, line 49
def type_tree node = nil
        roots = root
        converter = proc {|items, node|
                out = items.select { |item|
                        node.nil? || (item.inherit_node.id != node.id && 
                                (node.parent_node.nil? || item.inherit_node.id != node.parent_node.id))
                }.collect { |item|
                        {:id=>item.id,:label=>item.label,:inherit_node_id=>item.inherit_node.id, :children=>converter.call(item.children, node)}
                }
        }
        
        converter.call(roots, node)
end