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, bundle, #data, #id_of, #key_exists_spec_differs, #local, #output_of, #output_with_children, #pretty_generate, #provider, #resource, #resource_names, #resources, #template, #tf_safe, #var

Constructor Details

#initializeRootContext

Returns a new instance of RootContext.



301
302
303
304
305
# File 'lib/terrafying/generator.rb', line 301

def initialize
  super

  PROVIDER_DEFAULTS.each { |name, spec| provider(name, spec) }
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(fn, *args) ⇒ Object



319
320
321
# File 'lib/terrafying/generator.rb', line 319

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

Instance Method Details

#backend(name, spec) ⇒ Object



307
308
309
310
311
312
313
# File 'lib/terrafying/generator.rb', line 307

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

#generate(&block) ⇒ Object



315
316
317
# File 'lib/terrafying/generator.rb', line 315

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