Module: Eco::Data::Locations::NodeBase::Treeify
- Includes:
- Language::AuxiliarLogger
- Defined in:
- lib/eco/data/locations/node_base/treeify.rb
Overview
Note:
expects nodes to have these properties:
id,nameandparentIdparenttracked_level
Generic treeifier
Instance Attribute Summary
Attributes included from Language::AuxiliarLogger
Instance Method Summary collapse
-
#treeify(nodes) {|NodeBase| ... } ⇒ Array<Hash>
A hierarchical tree of nested Hashes via
nodeskey.
Methods included from Language::AuxiliarLogger
Instance Method Details
#treeify(nodes) {|NodeBase| ... } ⇒ Array<Hash>
Note:
if block is no given, it auto-detects the serializer block.
Returns a hierarchical tree of nested Hashes via nodes key.
15 16 17 18 19 |
# File 'lib/eco/data/locations/node_base/treeify.rb', line 15 def treeify(nodes, &block) return [] if nodes.empty? block ||= nodes.first.class.serializer get_children(nil, parents_hash(nodes), &block) end |