Module: CukeModeler::Containing
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(&block) ⇒ Object
Executes the given code block with this model and every model that is a child of this model.
-
#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(&block) ⇒ Object
Executes the given code block with this model and every model that is a child of this model. Exact order of model tree traversal is not guaranteed beyond the first model traversed, which will be the model that called this method.
16 17 18 19 20 21 22 23 |
# File 'lib/cuke_modeler/containing.rb', line 16 def each(&block) if block block.call(self) children.each { |child| child.each(&block) } else to_enum(:each) end end |
#each_descendant(&block) ⇒ Object
Executes the given code block with every model that is a child of this model. DEPRECATED: use Enumerable module methods instead
27 28 29 30 31 32 |
# File 'lib/cuke_modeler/containing.rb', line 27 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. DEPRECATED: use Enumerable module methods instead
36 37 38 39 40 |
# File 'lib/cuke_modeler/containing.rb', line 36 def each_model(&block) block.call(self) each_descendant(&block) end |