summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2008-07-30 11:04:01 -0500
committerLuke Kanies <luke@madstop.com>2008-07-30 11:04:01 -0500
commit8033bd4b7398785048cf789698c1b341049c5983 (patch)
treec2b2030c4aa1da4d088b550d25071a564aa715e6 /lib
parent3405841140ad118a500f44b6d35c9977b5eca473 (diff)
downloadpuppet-8033bd4b7398785048cf789698c1b341049c5983.tar.gz
puppet-8033bd4b7398785048cf789698c1b341049c5983.tar.xz
puppet-8033bd4b7398785048cf789698c1b341049c5983.zip
Moving validation from FormatHandler to Format.
Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/network/format.rb2
-rw-r--r--lib/puppet/network/format_handler.rb9
2 files changed, 2 insertions, 9 deletions
diff --git a/lib/puppet/network/format.rb b/lib/puppet/network/format.rb
index 832697836..256e9a8d4 100644
--- a/lib/puppet/network/format.rb
+++ b/lib/puppet/network/format.rb
@@ -9,7 +9,7 @@ class Puppet::Network::Format
attr_accessor :mime
def initialize(name, options = {}, &block)
- @name = name
+ @name = name.to_s.downcase.intern
if mime = options[:mime]
@mime = mime
diff --git a/lib/puppet/network/format_handler.rb b/lib/puppet/network/format_handler.rb
index e42cc4c46..6700c42a8 100644
--- a/lib/puppet/network/format_handler.rb
+++ b/lib/puppet/network/format_handler.rb
@@ -40,17 +40,14 @@ module Puppet::Network::FormatHandler
end
def convert_from(format, data)
- raise ArgumentError, "Format %s not supported" % format unless support_format?(format)
format_handler.format(format).intern(self, data)
end
def convert_from_multiple(format, data)
- raise ArgumentError, "Format %s not supported" % format unless support_format?(format)
format_handler.format(format).intern_multiple(self, data)
end
def render_multiple(format, instances)
- raise ArgumentError, "Format %s not supported" % format unless support_format?(format)
format_handler.format(format).render_multiple(instances)
end
@@ -77,11 +74,7 @@ module Puppet::Network::FormatHandler
module InstanceMethods
def render(format = nil)
- if format
- raise ArgumentError, "Format %s not supported" % format unless support_format?(format)
- else
- format = self.class.default_format
- end
+ format ||= self.class.default_format
Puppet::Network::FormatHandler.format(format).render(self)
end