Module: CukeModeler::Nested Private
- Included in:
- Model
- Defined in:
- lib/cuke_modeler/nested.rb
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 are nested inside of other models. Internal helper class.
Instance Attribute Summary collapse
-
#parent_model ⇒ Object
The parent model that contains this model.
Instance Method Summary collapse
-
#get_ancestor(ancestor_type) ⇒ Model?
Returns the ancestor model of this model that matches the given type.
Instance Attribute Details
#parent_model ⇒ Object
The parent model that contains this model
12 13 14 |
# File 'lib/cuke_modeler/nested.rb', line 12 def parent_model @parent_model end |
Instance Method Details
#get_ancestor(ancestor_type) ⇒ Model?
Returns the ancestor model of this model that matches the given type. Available types are simply snake_case versions of the model Class names. Additionally, a special type :test will return either a Scenario or an Outline model.
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/cuke_modeler/nested.rb', line 28 def get_ancestor(ancestor_type) target_classes = classes_for_type(ancestor_type) raise(ArgumentError, "Unknown ancestor type '#{ancestor_type}'.") if target_classes.nil? ancestor = parent_model ancestor = ancestor.parent_model until target_classes.include?(ancestor.class) || ancestor.nil? ancestor end |