Commit d1b4a956f2afe33fd9855a10bb7c831e9e3549cf

  • Tree SHA1: 0bb1aa2
  • Parent SHA1: 305ae63 (Fixed bug where the trunk version of CouchDB doesn't accept document IDs that contain / in the url. They have to be encoded as %2F)
  • raw diff | raw patch
Added threading when saving has_many relations in case the child does some time consuming task in a call back. Removed ruby2ruby gem which isn't needed at the moment but as a result six specs fail. TODO: move ruby view server to a gem of its own
  
1111end
1212
1313require 'json/add/core'
14require "ruby2ruby"
14require 'thread'
15
16# require "ruby2ruby" Is used by the ruby view server which is to be moved out of the gem
1517# require "htmlentities" # if you want the UTILS::decode_strings to
1618 # replace characters like ø with ΓΈ
1719 # then this has to be included...
  
410410 state_before_wants_to_load_relations = @do_not_load_has_many_relations
411411 @do_not_load_has_many_relations = true
412412
413 # We thread the save process in case the relations do
414 # some funky time consuming stuff in their call backs
415 threads = []
413416 has_many.each do |thing_it_has_many_of|
414417 self.send(thing_it_has_many_of).each do |related_object|
415 related_object.save(location)
418 threads << Thread.new(related_object) do |object_to_save|
419 object_to_save.save(location)
420 end
416421 end
417422 end
423 threads.each {|thr| thr.join}
418424
419425 # Save all the has_one relations
420426 has_one.each do |thing_it_has_one_of|