Method: Customize::Inherited::ClassMethods#type_tree
- Defined in:
- lib/customize/inherited.rb
#type_tree(node = nil) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 |
# 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 |