Class: GeoEngineer::Provider

Inherits:
Object
  • Object
show all
Includes:
HasAttributes
Defined in:
lib/geoengineer/provider.rb

Overview

Outputs are mapped 1:1 to terraform outputs

Terraform Docs

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#idObject (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_idObject


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_terraformObject

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_jsonObject


35
36
37
# File 'lib/geoengineer/provider.rb', line 35

def to_terraform_json
  { id.to_s => terraform_attributes }
end