Class: Tdc::Generators::StandardGenerator
- Inherits:
-
GeneratorBase
- Object
- GeneratorBase
- Tdc::Generators::StandardGenerator
- Includes:
- DefinitionSourcable
- Defined in:
- lib/tdc/generators/standard_generator.rb
Overview
Knows how to provide a configurable instance definition.
Instance Attribute Summary collapse
-
#instance_definition ⇒ Object
readonly
Returns the value of attribute instance_definition.
Attributes inherited from GeneratorBase
Instance Method Summary collapse
- #generate ⇒ Object
-
#generate_instance ⇒ Object
Hook method: subclasses are expected to define how to generate a model instance.
-
#run_definition_resolvers(_instance_definition) ⇒ Object
Hook method: subclasses may include the DefinitionResolvable concern to override.
- #run_resolvers_and_generate_instance ⇒ Object
Methods included from DefinitionSourcable
Methods inherited from GeneratorBase
#initialize, #instance_definitions
Constructor Details
This class inherits a constructor from Tdc::Generators::GeneratorBase
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Tdc::Generators::DefinitionSourcable
Instance Attribute Details
#instance_definition ⇒ Object (readonly)
Returns the value of attribute instance_definition.
9 10 11 |
# File 'lib/tdc/generators/standard_generator.rb', line 9 def instance_definition @instance_definition end |
Instance Method Details
#generate ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/tdc/generators/standard_generator.rb', line 13 def generate CatalogEntries.new.tap do |catalog_entries| instance_definitions.each do |instance_definition| configure_instance_definition(instance_definition) # Delete the tag so that the models do not need to filter it out. tag = instance_definition.delete("tag") generated = run_resolvers_and_generate_instance # Add generated instance to the catalog entries whenever a tag provided. catalog_entries.add_catalog_entry(tag, generated) if tag end end end |
#generate_instance ⇒ Object
Hook method: subclasses are expected to define how to generate a model instance.
39 40 41 |
# File 'lib/tdc/generators/standard_generator.rb', line 39 def generate_instance raise Tdc::MissingOverrideError, "Implement the 'generate_instance' method" end |
#run_definition_resolvers(_instance_definition) ⇒ Object
Hook method: subclasses may include the DefinitionResolvable concern to override.
46 47 48 |
# File 'lib/tdc/generators/standard_generator.rb', line 46 def run_definition_resolvers(_instance_definition) # Do nothing end |
#run_resolvers_and_generate_instance ⇒ Object
29 30 31 32 33 34 |
# File 'lib/tdc/generators/standard_generator.rb', line 29 def run_resolvers_and_generate_instance run_extended_attribute_interpreters(instance_definition) run_definition_resolvers(instance_definition) generate_instance end |