Class: Compo::Composites::Leaf

Inherits:
Object
  • Object
show all
Includes:
Composite
Defined in:
lib/compo/composites/leaf.rb

Overview

A Composite that cannot have children

Add/remove operations on a leaf composite always fail, and #children always returns the empty hash.

This is useful for leaf classes that still need to expose the composite API.

Direct Known Subclasses

Branches::Leaf

Instance Method Summary collapse

Methods included from Composite

#add, #get_child, #get_child_such_that, #remove, #remove_id

Instance Method Details

#childrenHash

Returns the empty hash

Examples:

Gets the children

comp.children
#=> {}

Returns:

  • (Hash)

    The empty hash.



23
24
25
# File 'lib/compo/composites/leaf.rb', line 23

def children
  {}
end