Class: Compo::HashBranch

Inherits:
HashComposite show all
Includes:
Movable, ParentTracker, UrlReferenceable
Defined in:
lib/compo/hash_branch.rb

Overview

A simple implementation of a branch, whose children are stored in an Hash

An HashBranch is a composite object that may be moved into other composite objects. It stores its children as an Hash, and the ID of each child is its hash key. Inserting and removing items into the HashBranch will not change the IDs of other items, but inserting with an existing key will remove the previous occupant.

This is an extension of HashComposite to include the Movable and ParentTracker mixins.

Instance Attribute Summary

Attributes included from ParentTracker

#parent

Attributes inherited from HashComposite

#children

Instance Method Summary collapse

Methods included from UrlReferenceable

#parent_url, #url

Methods included from ParentTracker

#remove_parent, #update_parent

Methods included from Movable

#move_to

Methods included from Composite

#add, #get_child, #remove, #remove_id

Constructor Details

#initializeHashBranch

Initialises the HashBranch

The HashBranch is created with no children, no parent, and no ID.

Examples:

Creates a new HashBranch.

branch = HashBranch.new


24
25
26
27
# File 'lib/compo/hash_branch.rb', line 24

def initialize
  super()
  remove_parent
end