Module: Tana::Models
- Defined in:
- lib/tana/models/node.rb,
lib/tana/models/root.rb
Constant Summary collapse
- Node =
A generic node.
Data.define :id, :name, :description, :type, :children do def self.for(**attributes) = new(**attributes.transform_keys!(nodeId: :id)) def initialize id:, type:, name: nil, description: nil, children: Core::EMPTY_ARRAY updated_children = children.map { |child| self.class.for(**child) } super id:, name:, type:, description:, children: updated_children end alias_method :to_hash, :to_h end
- Root =
A root node.
Data.define :children do def self.for(node: Node, **attributes) attributes.fetch(:children, Core::EMPTY_ARRAY) .map { |child| node.for(**child) } .then { |children| new children: } end end