Class: Terrafying::RootContext
- Defined in:
- lib/terrafying/generator.rb
Constant Summary
Constants inherited from Context
Context::PROVIDER_DEFAULTS, Context::REGION
Instance Attribute Summary
Attributes inherited from Context
Instance Method Summary collapse
- #backend(name, spec) ⇒ Object
- #generate(&block) ⇒ Object
-
#initialize ⇒ RootContext
constructor
A new instance of RootContext.
- #method_missing(fn, *args) ⇒ Object
- #output_with_children ⇒ Object
Methods inherited from Context
#add!, #aws, bundle, #data, #id_of, #key_exists_spec_differs, #local, #output_of, #pretty_generate, #provider, #provider_key, #required_provider, #required_version, #resource, #resource_names, #resources, #template, #tf_module, #tf_safe, #var
Constructor Details
#initialize ⇒ RootContext
Returns a new instance of RootContext.
325 326 327 328 |
# File 'lib/terrafying/generator.rb', line 325 def initialize super @providers = {} end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(fn, *args) ⇒ Object
342 343 344 |
# File 'lib/terrafying/generator.rb', line 342 def method_missing(fn, *args) resource(fn, args.shift.to_s, args.first) end |
Instance Method Details
#backend(name, spec) ⇒ Object
330 331 332 333 334 335 336 |
# File 'lib/terrafying/generator.rb', line 330 def backend(name, spec) @output['terraform'] = { backend: { name => spec } } end |
#generate(&block) ⇒ Object
338 339 340 |
# File 'lib/terrafying/generator.rb', line 338 def generate(&block) instance_eval(&block) end |
#output_with_children ⇒ Object
346 347 348 349 350 351 352 353 354 |
# File 'lib/terrafying/generator.rb', line 346 def output_with_children PROVIDER_DEFAULTS.each do |name, spec| unless key_exists_spec_differs(provider_key(name, spec), name, spec) provider(name, spec) end end super end |