Class: Compo::ArrayBranch

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

Overview

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

An ArrayBranch is a composite object that may be moved into other composite objects. It stores its children as an Array, and the ID of each child is its current index in the array. Inserting and removing items into the ArrayBranch may change the IDs of items with higher indices in the array.

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

Instance Attribute Summary

Attributes included from ParentTracker

#parent

Instance Method Summary collapse

Methods included from UrlReferenceable

#child_url, #parent_url, #url

Methods included from ParentTracker

#remove_parent, #update_parent

Methods included from Movable

#move_to

Methods inherited from ArrayComposite

#children

Methods included from Composite

#add, #get_child, #remove, #remove_id

Constructor Details

#initializeArrayBranch

Initialises the ArrayBranch

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

Examples:

Creates a new ArrayBranch.

branch = ArrayBranch.new


23
24
25
26
# File 'lib/compo/array_branch.rb', line 23

def initialize
  super()
  remove_parent
end