# File lib/puppet/type.rb, line 243
243:   def self.newproperty(name, options = {}, &block)
244:     name = symbolize(name)
245: 
246:     # This is here for types that might still have the old method of defining
247:     # a parent class.
248:     unless options.is_a? Hash
249:       raise Puppet::DevError,
250:         "Options must be a hash, not #{options.inspect}"
251:     end
252: 
253:     raise Puppet::DevError, "Class #{self.name} already has a property named #{name}" if @validproperties.include?(name)
254: 
255:     if parent = options[:parent]
256:       options.delete(:parent)
257:     else
258:       parent = Puppet::Property
259:     end
260: 
261:     # We have to create our own, new block here because we want to define
262:     # an initial :retrieve method, if told to, and then eval the passed
263:     # block if available.
264:     prop = genclass(name, :parent => parent, :hash => @validproperties, :attributes => options) do
265:       # If they've passed a retrieve method, then override the retrieve
266:       # method on the class.
267:       if options[:retrieve]
268:         define_method(:retrieve) do
269:           provider.send(options[:retrieve])
270:         end
271:       end
272: 
273:       class_eval(&block) if block
274:     end
275: 
276:     # If it's the 'ensure' property, always put it first.
277:     if name == :ensure
278:       @properties.unshift prop
279:     else
280:       @properties << prop
281:     end
282: 
283:     prop
284:   end