Method: Puppet::Pal::CatalogCompiler#with_json_encoding

Defined in:
lib/puppet/pal/catalog_compiler.rb

#with_json_encoding(pretty: true, exclude_virtual: true) {|JsonCatalogEncoder.new(catalog, pretty: pretty, exclude_virtual: exclude_virtual)| ... } ⇒ Object

Calls a block of code and yields a configured ‘JsonCatalogEncoder` to the block.

Examples:

Get resulting catalog as pretty printed Json

Puppet::Pal.in_environment(...) do |pal|
  pal.with_catalog_compiler(...) do |compiler|
    compiler.with_json_encoding { |encoder| encoder.encode }
  end
end

Yields:



36
37
38
# File 'lib/puppet/pal/catalog_compiler.rb', line 36

def with_json_encoding(pretty: true, exclude_virtual: true)
  yield JsonCatalogEncoder.new(catalog, pretty: pretty, exclude_virtual: exclude_virtual)
end