class HCL::Generator

Attributes

body[R]
doc[R]

Public Class Methods

inject!() click to toggle source

Inject to_hcl methods into the Ruby classes used by HCL (booleans, String, Numeric, Array). You can add to_hcl methods to your own classes to allow them to be easily serialized by the generator (and it will shout if something doesn't have a to_hcl method).

# File lib/hcl/generator.rb, line 21
def self.inject!
  return if @@injected
  require 'hcl/monkey_patch'
  @@injected = true
end
new(doc) click to toggle source
# File lib/hcl/generator.rb, line 4
def initialize(doc)
  # Ensure all the to_hcl methods are injected into the base Ruby classes
  # used by HCL.
  self.class.inject!

  @doc = doc
  @body = doc.to_hcl

  return @body
end