Module: CukeModeler::Containing
- Included in:
- Model
- Defined in:
- lib/cuke_modeler/containing.rb
Overview
NOT A PART OF THE PUBLIC API A mix-in module containing methods used by models that contain other models.
Instance Method Summary collapse
-
#each_descendant(&block) ⇒ Object
Executes the given code block with every model that is a child of this model.
-
#each_model(&block) ⇒ Object
Executes the given code block with this model and every model that is a child of this model.
Instance Method Details
#each_descendant(&block) ⇒ Object
Executes the given code block with every model that is a child of this model.
9 10 11 12 13 14 |
# File 'lib/cuke_modeler/containing.rb', line 9 def each_descendant(&block) children.each do |child_model| block.call(child_model) child_model.each_descendant(&block) if child_model.respond_to?(:each_descendant) end end |
#each_model(&block) ⇒ Object
Executes the given code block with this model and every model that is a child of this model.
17 18 19 20 21 |
# File 'lib/cuke_modeler/containing.rb', line 17 def each_model(&block) block.call(self) each_descendant(&block) end |