# File lib/puppet/rails/resource.rb, line 198
198:   def to_resource(scope)
199:     hash = self.attributes
200:     hash["type"] = hash["restype"]
201:     hash.delete("restype")
202: 
203:     # FIXME At some point, we're going to want to retain this information
204:     # for logging and auditing.
205:     hash.delete("host_id")
206:     hash.delete("updated_at")
207:     hash.delete("source_file_id")
208:     hash.delete("created_at")
209:     hash.delete("id")
210:     hash.each do |p, v|
211:       hash.delete(p) if v.nil?
212:     end
213:     hash[:scope] = scope
214:     hash[:source] = scope.source
215:     hash[:parameters] = []
216:     names = []
217:     self.param_names.each do |pname|
218:       # We can get the same name multiple times because of how the
219:       # db layout works.
220:       next if names.include?(pname.name)
221:       names << pname.name
222:       hash[:parameters] << pname.to_resourceparam(self, scope.source)
223:     end
224:     obj = Puppet::Parser::Resource.new(hash.delete("type"), hash.delete("title"), hash)
225: 
226:     # Store the ID, so we can check if we're re-collecting the same resource.
227:     obj.rails_id = self.id
228: 
229:     obj
230:   end