module Puppet::Network::FormatSupport::ClassMethods

Public Instance Methods

convert_from(format, data) click to toggle source
# File lib/puppet/network/format_support.rb, line 11
def convert_from(format, data)
  get_format(format).intern(self, data)
rescue => err
  raise Puppet::Network::FormatHandler::FormatError, "Could not intern from #{format}: #{err}", err.backtrace
end
convert_from_multiple(format, data) click to toggle source
# File lib/puppet/network/format_support.rb, line 17
def convert_from_multiple(format, data)
  get_format(format).intern_multiple(self, data)
rescue => err
  raise Puppet::Network::FormatHandler::FormatError, "Could not intern_multiple from #{format}: #{err}", err.backtrace
end
default_format() click to toggle source
# File lib/puppet/network/format_support.rb, line 29
def default_format
  supported_formats[0]
end
get_format(format_name) click to toggle source

@api private

# File lib/puppet/network/format_support.rb, line 57
def get_format(format_name)
  format_handler.format_for(format_name)
end
render_multiple(format, instances) click to toggle source
# File lib/puppet/network/format_support.rb, line 23
def render_multiple(format, instances)
  get_format(format).render_multiple(instances)
rescue => err
  raise Puppet::Network::FormatHandler::FormatError, "Could not render_multiple to #{format}: #{err}", err.backtrace
end
support_format?(name) click to toggle source
# File lib/puppet/network/format_support.rb, line 33
def support_format?(name)
  Puppet::Network::FormatHandler.format(name).supported?(self)
end
supported_formats() click to toggle source
# File lib/puppet/network/format_support.rb, line 37
def supported_formats
  result = format_handler.formats.collect do |f|
    format_handler.format(f)
  end.find_all do |f|
    f.supported?(self)
  end.sort do |a, b|
    # It's an inverse sort -- higher weight formats go first.
    b.weight <=> a.weight
  end.collect do |f|
    f.name
  end

  result = put_preferred_format_first(result)

  Puppet.debug "#{friendly_name} supports formats: #{result.join(' ')}"

  result
end