Class: Compo::NullComposite

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

Overview

Null implementation of Composite

Add/remove operations on NullComposite 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

Leaf

Instance Method Summary collapse

Methods included from Composite

#add, #get_child, #remove, #remove_id

Instance Method Details

#childrenHash

Returns the empty hash

Examples:

Gets the children

comp.children
#=> {}

Returns:

  • (Hash)

    The empty hash.



22
23
24
# File 'lib/compo/null_composite.rb', line 22

def children
  {}
end