Commit d1b4a956f2afe33fd9855a10bb7c831e9e3549cf
- Diff rendering mode:
- inline
- side by side
lib/couch_object.rb
(3 / 1)
|   | |||
| 11 | 11 | end | |
| 12 | 12 | ||
| 13 | 13 | require 'json/add/core' | |
| 14 | require "ruby2ruby" | ||
| 14 | require 'thread' | ||
| 15 | |||
| 16 | # require "ruby2ruby" Is used by the ruby view server which is to be moved out of the gem | ||
| 15 | 17 | # require "htmlentities" # if you want the UTILS::decode_strings to | |
| 16 | 18 | # replace characters like ø with ΓΈ | |
| 17 | 19 | # then this has to be included... |
|   | |||
| 410 | 410 | state_before_wants_to_load_relations = @do_not_load_has_many_relations | |
| 411 | 411 | @do_not_load_has_many_relations = true | |
| 412 | 412 | ||
| 413 | # We thread the save process in case the relations do | ||
| 414 | # some funky time consuming stuff in their call backs | ||
| 415 | threads = [] | ||
| 413 | 416 | has_many.each do |thing_it_has_many_of| | |
| 414 | 417 | 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 | ||
| 416 | 421 | end | |
| 417 | 422 | end | |
| 423 | threads.each {|thr| thr.join} | ||
| 418 | 424 | ||
| 419 | 425 | # Save all the has_one relations | |
| 420 | 426 | has_one.each do |thing_it_has_one_of| |

