module Sabrina::ChildrenManager

Implements attr_children, an attr_accessor-like macro that allows passing down attribute write calls to an arbitrary array of objects. Obviously, the child objects should support writing to the specified attributes.

Classes should override #children to return a meaningful array of child objects.

Public Class Methods

included(mod) click to toggle source

Magic for adding class methods when included.

# File lib/sabrina/children_manager.rb, line 47
def included(mod)
  mod.extend(AttrChildren)
end

Public Instance Methods

children() click to toggle source

Classes should override this to provide a meaningful array of children.

@return [Array]

# File lib/sabrina/children_manager.rb, line 56
def children
  instance_variable_defined?(:@children) ? @children : []
end