diff options
author | Luke Kanies <luke@madstop.com> | 2008-12-11 12:31:01 -0600 |
---|---|---|
committer | Luke Kanies <luke@madstop.com> | 2008-12-18 11:10:23 -0600 |
commit | fae30756e48184dfc8238dcfe80b843f981b6070 (patch) | |
tree | 9de8d66a6cd9a73b720786a25843e837048ec628 /lib/puppet | |
parent | 14c3c54ee1976e1c76acfe62554bb1786da6427b (diff) | |
download | puppet-fae30756e48184dfc8238dcfe80b843f981b6070.tar.gz puppet-fae30756e48184dfc8238dcfe80b843f981b6070.tar.xz puppet-fae30756e48184dfc8238dcfe80b843f981b6070.zip |
Simplifying the initialization interface for References
You previously had to call new(nil, "Foo[bar]") if you
just had the resource reference as a string. Now
you can call new("Foo[bar]"), but the old behaviour
works, too.
Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'lib/puppet')
-rw-r--r-- | lib/puppet/resource/reference.rb | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/lib/puppet/resource/reference.rb b/lib/puppet/resource/reference.rb index d254254aa..d17b3e558 100644 --- a/lib/puppet/resource/reference.rb +++ b/lib/puppet/resource/reference.rb @@ -21,12 +21,17 @@ class Puppet::Resource::Reference builtin_type ? true : false end - def initialize(type, title) - # This will set @type if it looks like a resource reference. - self.title = title + def initialize(argtype, argtitle = nil) + if argtitle.nil? + self.title = argtype + raise ArgumentError, "No title provided and title '%s' is not a valid resource reference" % argtype if self.title == argtype + else + # This will set @type if it looks like a resource reference. + self.title = argtitle - # Don't override whatever was done by setting the title. - self.type = type if self.type.nil? + # Don't override whatever was done by setting the title. + self.type ||= argtype + end @builtin_type = nil end |