Module: Puppet::Network::FormatHandler::ClassMethods

Defined in:
lib/vendor/puppet/network/format_handler.rb

Instance Method Summary collapse

Instance Method Details

#convert_from(format, data) ⇒ Object



107
108
109
# File 'lib/vendor/puppet/network/format_handler.rb', line 107

def convert_from(format, data)
  format_handler.protected_format(format).intern(self, data)
end

#convert_from_multiple(format, data) ⇒ Object



111
112
113
# File 'lib/vendor/puppet/network/format_handler.rb', line 111

def convert_from_multiple(format, data)
  format_handler.protected_format(format).intern_multiple(self, data)
end

#default_formatObject



119
120
121
# File 'lib/vendor/puppet/network/format_handler.rb', line 119

def default_format
  supported_formats[0]
end

#format_handlerObject



103
104
105
# File 'lib/vendor/puppet/network/format_handler.rb', line 103

def format_handler
  Puppet::Network::FormatHandler
end

#render_multiple(format, instances) ⇒ Object



115
116
117
# File 'lib/vendor/puppet/network/format_handler.rb', line 115

def render_multiple(format, instances)
  format_handler.protected_format(format).render_multiple(instances)
end

#support_format?(name) ⇒ Boolean

Returns:

  • (Boolean)


123
124
125
# File 'lib/vendor/puppet/network/format_handler.rb', line 123

def support_format?(name)
  Puppet::Network::FormatHandler.format(name).supported?(self)
end

#supported_formatsObject



127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/vendor/puppet/network/format_handler.rb', line 127

def supported_formats
  result = format_handler.formats.collect { |f| format_handler.format(f) }.find_all { |f| f.supported?(self) }.collect { |f| f.name }.sort do |a, b|
    # It's an inverse sort -- higher weight formats go first.
    format_handler.format(b).weight <=> format_handler.format(a).weight
  end

  result = put_preferred_format_first(result)

  Puppet.debug "#{friendly_name} supports formats: #{result.map{ |f| f.to_s }.sort.join(' ')}; using #{result.first}"

  result
end