Module: Puppet::Network::FormatSupport::ClassMethods
- Defined in:
- lib/puppet/network/format_support.rb
Instance Method Summary collapse
- #convert_from(format, data) ⇒ Object
- #convert_from_multiple(format, data) ⇒ Object
- #default_format ⇒ Object
- #get_format(format_name) ⇒ Object private
- #render_multiple(format, instances) ⇒ Object
- #support_format?(name) ⇒ Boolean
- #supported_formats ⇒ Object
Instance Method Details
#convert_from(format, data) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/puppet/network/format_support.rb', line 12 def convert_from(format, data) get_format(format).intern(self, data) rescue => err #TRANSLATORS "intern" is a function name and should not be translated raise Puppet::Network::FormatHandler::FormatError, _("Could not intern from %{format}: %{err}") % { format: format, err: err }, err.backtrace end |
#convert_from_multiple(format, data) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/puppet/network/format_support.rb', line 19 def convert_from_multiple(format, data) get_format(format).intern_multiple(self, data) rescue => err #TRANSLATORS "intern_multiple" is a function name and should not be translated raise Puppet::Network::FormatHandler::FormatError, _("Could not intern_multiple from %{format}: %{err}") % { format: format, err: err }, err.backtrace end |
#default_format ⇒ Object
33 34 35 |
# File 'lib/puppet/network/format_support.rb', line 33 def default_format supported_formats[0] end |
#get_format(format_name) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
59 60 61 |
# File 'lib/puppet/network/format_support.rb', line 59 def get_format(format_name) format_handler.format_for(format_name) end |
#render_multiple(format, instances) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/puppet/network/format_support.rb', line 26 def render_multiple(format, instances) get_format(format).render_multiple(instances) rescue => err #TRANSLATORS "render_multiple" is a function name and should not be translated raise Puppet::Network::FormatHandler::FormatError, _("Could not render_multiple to %{format}: %{err}") % { format: format, err: err }, err.backtrace end |
#support_format?(name) ⇒ Boolean
37 38 39 |
# File 'lib/puppet/network/format_support.rb', line 37 def support_format?(name) Puppet::Network::FormatHandler.format(name).supported?(self) end |
#supported_formats ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/puppet/network/format_support.rb', line 41 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 result = put_preferred_format_first(result).map(&:name) Puppet.debug { "#{friendly_name} supports formats: #{result.join(' ')}" } result end |