Module: Puppet::Network::FormatSupport
- Included in:
- ModuleTool::Checksums, ModuleTool::Dependency, ModuleTool::Metadata, Relationship, Resource::Status, Transaction::Event, Util::Log, Util::Metric, Util::TagSet
- Defined in:
- lib/puppet/network/format_support.rb
Overview
Provides network serialization support when included
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
- #mime(format = nil) ⇒ Object
- #render(format = nil) ⇒ Object
- #support_format?(name) ⇒ Boolean
-
#to_data_hash(*args) ⇒ Hash
abstract
This method may be implemented to return a hash object that is used for serializing.
- #to_json(*args) ⇒ Object
- #to_msgpack(*args) ⇒ Object
- #to_pson(*args) ⇒ Object
Class Method Details
.included(klass) ⇒ Object
6 7 8 |
# File 'lib/puppet/network/format_support.rb', line 6 def self.included(klass) klass.extend(ClassMethods) end |
Instance Method Details
#mime(format = nil) ⇒ Object
107 108 109 110 111 112 113 |
# File 'lib/puppet/network/format_support.rb', line 107 def mime(format = nil) format ||= self.class.default_format self.class.get_format(format).mime rescue => err raise Puppet::Network::FormatHandler::FormatError, "Could not mime to #{format}: #{err}", err.backtrace end |
#render(format = nil) ⇒ Object
99 100 101 102 103 104 105 |
# File 'lib/puppet/network/format_support.rb', line 99 def render(format = nil) format ||= self.class.default_format self.class.get_format(format).render(self) rescue => err raise Puppet::Network::FormatHandler::FormatError, "Could not render to #{format}: #{err}", err.backtrace end |
#support_format?(name) ⇒ Boolean
115 116 117 |
# File 'lib/puppet/network/format_support.rb', line 115 def support_format?(name) self.class.support_format?(name) end |
#to_data_hash(*args) ⇒ Hash
This method is abstract.
This method may be implemented to return a hash object that is used for serializing. The object returned by this method should contain all the info needed to instantiate it again. If the method exists it will be called from to_msgpack and other serialization methods.
|
# File 'lib/puppet/network/format_support.rb', line 119
|
#to_json(*args) ⇒ Object
95 96 97 |
# File 'lib/puppet/network/format_support.rb', line 95 def to_json(*args) to_data_hash.to_json(*args) end |
#to_msgpack(*args) ⇒ Object
87 88 89 |
# File 'lib/puppet/network/format_support.rb', line 87 def to_msgpack(*args) to_data_hash.to_msgpack(*args) end |
#to_pson(*args) ⇒ Object
91 92 93 |
# File 'lib/puppet/network/format_support.rb', line 91 def to_pson(*args) to_data_hash.to_pson(*args) end |