Class: Terrafying::RootContext

Inherits:
Context
  • Object
show all
Defined in:
lib/terrafying/generator.rb

Constant Summary

Constants inherited from Context

Context::PROVIDER_DEFAULTS, Context::REGION

Instance Attribute Summary

Attributes inherited from Context

#output

Instance Method Summary collapse

Methods inherited from Context

#add!, #aws, #data, #id_of, #output_of, #output_with_children, #pretty_generate, #provider, #resource, #resource_names, #resources, #template, #tf_safe

Constructor Details

#initializeRootContext

Returns a new instance of RootContext.



108
109
110
111
112
# File 'lib/terrafying/generator.rb', line 108

def initialize
  super

  output["provider"] = PROVIDER_DEFAULTS
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(fn, *args) ⇒ Object



126
127
128
# File 'lib/terrafying/generator.rb', line 126

def method_missing(fn, *args)
  resource(fn, args.shift.to_s, args.first)
end

Instance Method Details

#backend(name, spec) ⇒ Object



114
115
116
117
118
119
120
# File 'lib/terrafying/generator.rb', line 114

def backend(name, spec)
  @output["terraform"] = {
    backend: {
      name => spec,
    },
  }
end

#generate(&block) ⇒ Object



122
123
124
# File 'lib/terrafying/generator.rb', line 122

def generate(&block)
  instance_eval(&block)
end