summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/metatype/manager.rb15
-rw-r--r--lib/puppet/type.rb1
2 files changed, 15 insertions, 1 deletions
diff --git a/lib/puppet/metatype/manager.rb b/lib/puppet/metatype/manager.rb
index 53cb5951d..ee396389b 100644
--- a/lib/puppet/metatype/manager.rb
+++ b/lib/puppet/metatype/manager.rb
@@ -54,7 +54,13 @@ module Manager
end
# Define a new type.
- def newtype(name, parent = nil, &block)
+ def newtype(name, options = {}, &block)
+ # Handle backward compatibility
+ unless options.is_a?(Hash)
+ Puppet.warning "Puppet::Type.newtype now accepts a hash as the second argument"
+ options = {:parent => options}
+ end
+
# First make sure we don't have a method sitting around
name = symbolize(name)
newmethod = "new#{name.to_s}"
@@ -71,11 +77,18 @@ module Manager
end
end
+ options = symbolize_options(options)
+
+ if parent = options[:parent]
+ options.delete(:parent)
+ end
+
# Then create the class.
klass = genclass(name,
:parent => (parent || Puppet::Type),
:overwrite => true,
:hash => @types,
+ :attributes => options,
&block
)
diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb
index a81424b45..fb73e0459 100644
--- a/lib/puppet/type.rb
+++ b/lib/puppet/type.rb
@@ -50,6 +50,7 @@ class Type < Puppet::Element
# the Type class attribute accessors
class << self
attr_reader :name
+ attr_accessor :self_refresh
include Enumerable, Puppet::Util::ClassGen
include Puppet::MetaType::Manager
end