summaryrefslogtreecommitdiffstats
path: root/lib/puppet/network/formats.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/puppet/network/formats.rb')
-rw-r--r--lib/puppet/network/formats.rb54
1 files changed, 52 insertions, 2 deletions
diff --git a/lib/puppet/network/formats.rb b/lib/puppet/network/formats.rb
index 640a24485..79e2860af 100644
--- a/lib/puppet/network/formats.rb
+++ b/lib/puppet/network/formats.rb
@@ -1,4 +1,54 @@
require 'puppet/network/format_handler'
-Puppet::Network::FormatHandler.create(:yaml, :mime => "text/yaml")
-Puppet::Network::FormatHandler.create(:marshal, :mime => "text/marshal")
+Puppet::Network::FormatHandler.create(:yaml, :mime => "text/yaml") do
+ # Yaml doesn't need the class name; it's serialized.
+ def intern(klass, text)
+ YAML.load(text)
+ end
+
+ # Yaml doesn't need the class name; it's serialized.
+ def intern_multiple(klass, text)
+ YAML.load(text)
+ end
+
+ def render(instance)
+ instance.to_yaml
+ end
+
+ # Yaml monkey-patches Array, so this works.
+ def render_multiple(instances)
+ instances.to_yaml
+ end
+
+ # Everything's supported
+ def supported?(klass)
+ true
+ end
+end
+
+
+Puppet::Network::FormatHandler.create(:marshal, :mime => "text/marshal") do
+ # Yaml doesn't need the class name; it's serialized.
+ def intern(klass, text)
+ Marshal.load(text)
+ end
+
+ # Yaml doesn't need the class name; it's serialized.
+ def intern_multiple(klass, text)
+ Marshal.load(text)
+ end
+
+ def render(instance)
+ Marshal.dump(instance)
+ end
+
+ # Yaml monkey-patches Array, so this works.
+ def render_multiple(instances)
+ Marshal.dump(instances)
+ end
+
+ # Everything's supported
+ def supported?(klass)
+ true
+ end
+end