summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2007-01-28 22:54:32 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2007-01-28 22:54:32 +0000
commitbf46e7d363bbedc683abd63ab159ed170803009a (patch)
tree2d70322768d4024eb3db9ae9c0599eaaea288fb9 /lib
parent1f41c35c6c081c2f673d713588220e78d8c7c1b0 (diff)
downloadpuppet-bf46e7d363bbedc683abd63ab159ed170803009a.tar.gz
puppet-bf46e7d363bbedc683abd63ab159ed170803009a.tar.xz
puppet-bf46e7d363bbedc683abd63ab159ed170803009a.zip
Adding a "self_refresh" option, so resources can refresh themselves if they have changed in the current transaction.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2106 980ebf18-57e1-0310-9a29-db15c13687c0
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