Class: GeoEngineer::Template
- Inherits:
-
Object
- Object
- GeoEngineer::Template
- Includes:
- HasAttributes, HasResources
- Defined in:
- lib/geoengineer/template.rb
Overview
Override to define recommended patterns of resource use
Direct Known Subclasses
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#parameters ⇒ Object
Returns the value of attribute parameters.
-
#parent ⇒ Object
Returns the value of attribute parent.
Instance Method Summary collapse
- #add_env_attributes(environment) ⇒ Object
-
#add_project_attributes(project) ⇒ Object
Helper method to accomodate different parents.
- #all_resources ⇒ Object
-
#initialize(name, parent, parameters = {}) ⇒ Template
constructor
A new instance of Template.
- #resource(type, id, &block) ⇒ Object
-
#template_resources ⇒ Object
The resources that are passed to the block on instantiation This can be overridden to specify the order of the templates resources.
Methods included from HasResources
#create_resource, #find_resource, #find_resource_by_ref, included, #resources, #resources_grouped_by, #resources_of_type, #resources_of_type_grouped_by
Methods included from HasAttributes
#[], #[]=, #assign_attribute, #assign_block, #attribute_missing, #attribute_procs, #attributes, #delete, #eager_load_attributes, #method_missing, #reset_attributes, #retrieve_attribute, #terraform_attribute_ref, #terraform_attributes, #timeout
Constructor Details
#initialize(name, parent, parameters = {}) ⇒ Template
Returns a new instance of Template.
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/geoengineer/template.rb', line 10 def initialize(name, parent, parameters = {}) @name = name @parameters = parameters @parent = parent case parent when GeoEngineer::Project then add_project_attributes(parent) when GeoEngineer::Environment then add_env_attributes(parent) end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class HasAttributes
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
8 9 10 |
# File 'lib/geoengineer/template.rb', line 8 def name @name end |
#parameters ⇒ Object
Returns the value of attribute parameters.
8 9 10 |
# File 'lib/geoengineer/template.rb', line 8 def parameters @parameters end |
#parent ⇒ Object
Returns the value of attribute parent.
8 9 10 |
# File 'lib/geoengineer/template.rb', line 8 def parent @parent end |
Instance Method Details
#add_env_attributes(environment) ⇒ Object
27 28 29 |
# File 'lib/geoengineer/template.rb', line 27 def add_env_attributes(environment) @environment = environment end |
#add_project_attributes(project) ⇒ Object
Helper method to accomodate different parents
22 23 24 25 |
# File 'lib/geoengineer/template.rb', line 22 def add_project_attributes(project) @project = project @environment = project.environment end |
#all_resources ⇒ Object
40 41 42 |
# File 'lib/geoengineer/template.rb', line 40 def all_resources resources end |
#resource(type, id, &block) ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/geoengineer/template.rb', line 31 def resource(type, id, &block) return find_resource(type, id) unless block_given? resource = create_resource(type, id, &block) resource.template = self resource.environment = @environment resource.project = @project if @project resource end |
#template_resources ⇒ Object
The resources that are passed to the block on instantiation This can be overridden to specify the order of the templates resources
46 47 48 |
# File 'lib/geoengineer/template.rb', line 46 def template_resources resources end |