# File lib/puppet/type.rb, line 893
893:   def self.hash2resource(hash)
894:     hash = hash.inject({}) { |result, ary| result[ary[0].to_sym] = ary[1]; result }
895: 
896:     title = hash.delete(:title)
897:     title ||= hash[:name]
898:     title ||= hash[key_attributes.first] if key_attributes.length == 1
899: 
900:     raise Puppet::Error, "Title or name must be provided" unless title
901: 
902:     # Now create our resource.
903:     resource = Puppet::Resource.new(self.name, title)
904:     [:catalog].each do |attribute|
905:       if value = hash[attribute]
906:         hash.delete(attribute)
907:         resource.send(attribute.to_s + "=", value)
908:       end
909:     end
910: 
911:     hash.each do |param, value|
912:       resource[param] = value
913:     end
914:     resource
915:   end