Module: Sabrina::ChildrenManager
- Included in:
- Monster, Plugins::Spritesheet
- Defined in:
- lib/sabrina/children_manager.rb
Overview
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.
Defined Under Namespace
Modules: AttrChildren
Class Method Summary collapse
-
.included(mod) ⇒ Object
Magic for adding class methods when included.
Instance Method Summary collapse
-
#children ⇒ Array
Classes should override this to provide a meaningful array of children.
Class Method Details
.included(mod) ⇒ Object
Magic for adding class methods when included.
47 48 49 |
# File 'lib/sabrina/children_manager.rb', line 47 def included(mod) mod.extend(AttrChildren) end |
Instance Method Details
#children ⇒ Array
Classes should override this to provide a meaningful array of children.
56 57 58 |
# File 'lib/sabrina/children_manager.rb', line 56 def children instance_variable_defined?(:@children) ? @children : [] end |