Class: GeoEngineer::Provider
- Inherits:
-
Object
- Object
- GeoEngineer::Provider
- Includes:
- HasAttributes
- Defined in:
- lib/geoengineer/provider.rb
Overview
Outputs are mapped 1:1 to terraform outputs
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Instance Method Summary collapse
-
#initialize(id, &block) ⇒ Provider
constructor
A new instance of Provider.
- #terraform_id ⇒ Object
-
#to_terraform ⇒ Object
Terraform methods.
- #to_terraform_json ⇒ Object
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(id, &block) ⇒ Provider
Returns a new instance of Provider.
10 11 12 13 |
# File 'lib/geoengineer/provider.rb', line 10 def initialize(id, &block) @id = id instance_exec(self, &block) if block_given? end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class HasAttributes
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
7 8 9 |
# File 'lib/geoengineer/provider.rb', line 7 def id @id end |
Instance Method Details
#terraform_id ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/geoengineer/provider.rb', line 15 def terraform_id if self.alias "#{id}.#{self.alias}" else id end end |
#to_terraform ⇒ Object
Terraform methods
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/geoengineer/provider.rb', line 24 def to_terraform sb = ["provider #{@id.inspect} { "] sb.concat terraform_attributes.map { |k, v| " #{k.to_s.inspect} = #{v.inspect}" } sb << " }" sb.join("\n") end |
#to_terraform_json ⇒ Object
35 36 37 |
# File 'lib/geoengineer/provider.rb', line 35 def to_terraform_json { id.to_s => terraform_attributes } end |