Module: CukeModeler::Containing Private
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
A mix-in module containing methods used by models that contain other models. Internal helper class.
Instance Method Summary collapse
-
#each {|The| ... } ⇒ Enumerable
Executes the given code block with this model and every model that is a child of this model.
-
#each_descendant {|The| ... } ⇒ Object
deprecated
Deprecated.
Use ‘Enumerable` module methods instead
-
#each_model {|The| ... } ⇒ Object
deprecated
Deprecated.
Use ‘Enumerable` module methods instead
Instance Method Details
#each {|The| ... } ⇒ Enumerable
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. If no block is provided, an ‘Enumerator` is returned instead.
24 25 26 27 28 29 30 31 |
# File 'lib/cuke_modeler/containing.rb', line 24 def each(&block) if block block.call(self) children.each { |child| child.each(&block) } else to_enum(:each) end end |
#each_descendant {|The| ... } ⇒ Object
Use ‘Enumerable` module methods instead
Executes the given code block with every model that is a child of this model.
42 43 44 45 46 47 |
# File 'lib/cuke_modeler/containing.rb', line 42 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 {|The| ... } ⇒ Object
Use ‘Enumerable` module methods instead
Executes the given code block with this model and every model that is a child of this model.
58 59 60 61 62 |
# File 'lib/cuke_modeler/containing.rb', line 58 def each_model(&block) block.call(self) each_descendant(&block) end |