Class: Forester::TreeFactory
- Inherits:
-
Object
- Object
- Forester::TreeFactory
- Defined in:
- lib/forester/tree_factory.rb
Instance Method Summary collapse
Instance Method Details
#from_root_hash(root_hash, options = {}) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/forester/tree_factory.rb', line 3 def from_root_hash(root_hash, = {}) = { max_depth: :none, } = .merge() [:max_depth] = -2 if [:max_depth] == :none dummy_root = TreeNode.new('<TEMP>') tree = with_children(dummy_root, [root_hash], .fetch(:children_key), [:max_depth] + 1).first_child tree.detached_subtree_copy end |
#node_from_content(content) ⇒ Object
17 18 19 |
# File 'lib/forester/tree_factory.rb', line 17 def node_from_content(content) TreeNode.new(SecureRandom.uuid, content) end |