# File lib/puppet/type.rb, line 271
271:     def self.newproperty(name, options = {}, &block)
272:         name = symbolize(name)
273: 
274:         # This is here for types that might still have the old method of defining
275:         # a parent class.
276:         unless options.is_a? Hash
277:             raise Puppet::DevError,
278:                 "Options must be a hash, not %s" % options.inspect
279:         end
280: 
281:         if @validproperties.include?(name)
282:             raise Puppet::DevError, "Class %s already has a property named %s" %
283:                 [self.name, name]
284:         end
285: 
286:         if parent = options[:parent]
287:             options.delete(:parent)
288:         else
289:             parent = Puppet::Property
290:         end
291: 
292:         # We have to create our own, new block here because we want to define
293:         # an initial :retrieve method, if told to, and then eval the passed
294:         # block if available.
295:         prop = genclass(name, :parent => parent, :hash => @validproperties, :attributes => options) do
296:             # If they've passed a retrieve method, then override the retrieve
297:             # method on the class.
298:             if options[:retrieve]
299:                 define_method(:retrieve) do
300:                     provider.send(options[:retrieve])
301:                 end
302:             end
303: 
304:             if block
305:                 class_eval(&block)
306:             end
307:         end
308: 
309:         # If it's the 'ensure' property, always put it first.
310:         if name == :ensure
311:             @properties.unshift prop
312:         else
313:             @properties << prop
314:         end
315: 
316:         return prop
317:     end