Sha256: 383de4caf24172e9ebe1296ef5a027412a2602e490bb9b8f4d23b3c00b404656

Contents?: true

Size: 523 Bytes

Versions: 1

Compression:

Stored size: 523 Bytes

Contents

module OM::TreeNode

  attr_accessor :ancestors

  #  insert the mapper into the given parent
  def set_parent(parent_mapper)
    parent_mapper.children[@name] = self
    @ancestors << parent_mapper
  end

  #  insert the given mapper into the current mappers children
  def add_child(child_mapper)
    child_mapper.ancestors << self
    @children[child_mapper.name.to_sym] = child_mapper
  end

  def retrieve_child(child_name)
    child = @children.fetch(child_name, nil)
  end

  def parent
    ancestors.last
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
om-1.8.1 lib/om/tree_node.rb