Class: GeoEngineer::Project
- Inherits:
-
Object
- Object
- GeoEngineer::Project
- Includes:
- HasAttributes, HasLifecycle, HasResources, HasSubResources, HasTemplates, HasValidations
- Defined in:
- lib/geoengineer/project.rb
Overview
Projects are groups of resources used to organize and validate.
A Project contains resources, has arbitrary attributes and validation rules
Constant Summary
Constants included from HasValidations
HasValidations::MAX_POLICY_LENGTH
Instance Attribute Summary collapse
-
#environment ⇒ Object
readonly
Returns the value of attribute environment.
-
#name ⇒ Object
Returns the value of attribute name.
-
#org ⇒ Object
Returns the value of attribute org.
Instance Method Summary collapse
- #all_resources ⇒ Object
- #full_id_name ⇒ Object
- #full_name ⇒ Object
-
#initialize(org, name, environment, &block) ⇒ Project
constructor
A new instance of Project.
- #resource(type, id, &block) ⇒ Object
-
#to_dot ⇒ Object
dot method.
Methods included from HasValidations
#errors, included, #validate_at_least_one_present, #validate_cidr_block, #validate_only_one_present, #validate_policy_length, #validate_required_attributes
Methods included from HasSubResources
#assign_block, #attribute_missing, #delete_all_subresources, #delete_subresources_where, #subresources
Methods included from HasTemplates
#all_template_resources, #find_template, #from_template, #templates
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 HasLifecycle
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(org, name, environment, &block) ⇒ Project
Returns a new instance of Project.
20 21 22 23 24 25 26 |
# File 'lib/geoengineer/project.rb', line 20 def initialize(org, name, environment, &block) @org = org @name = name @environment = environment instance_exec(self, &block) if block_given? execute_lifecycle(:after, :initialize) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class HasAttributes
Instance Attribute Details
#environment ⇒ Object (readonly)
Returns the value of attribute environment.
15 16 17 |
# File 'lib/geoengineer/project.rb', line 15 def environment @environment end |
#name ⇒ Object
Returns the value of attribute name.
14 15 16 |
# File 'lib/geoengineer/project.rb', line 14 def name @name end |
#org ⇒ Object
Returns the value of attribute org.
14 15 16 |
# File 'lib/geoengineer/project.rb', line 14 def org @org end |
Instance Method Details
#all_resources ⇒ Object
44 45 46 |
# File 'lib/geoengineer/project.rb', line 44 def all_resources [resources, all_template_resources].flatten end |
#full_id_name ⇒ Object
28 29 30 |
# File 'lib/geoengineer/project.rb', line 28 def full_id_name "#{org}_#{name}".tr('-', '_') end |
#full_name ⇒ Object
32 33 34 |
# File 'lib/geoengineer/project.rb', line 32 def full_name "#{org}/#{name}" end |
#resource(type, id, &block) ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/geoengineer/project.rb', line 36 def resource(type, id, &block) return find_resource(type, id) unless block_given? resource = create_resource(type, id, &block) resource.project = self resource.environment = @environment resource end |
#to_dot ⇒ Object
dot method
49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/geoengineer/project.rb', line 49 def to_dot str = [" subgraph \"cluster_#{full_id_name}\" {"] str << " style = filled; color = lightgrey;" str << " label = <<B><FONT POINT-SIZE=\"24.0\">#{full_name}</FONT></B>>" nodes = all_resources.map do |res| " node [label=#{res.short_name.inspect}, shape=\"box\"] #{res.to_ref.inspect};" end str << nodes str << " }" str.join(" // #{full_name} \n") end |