motion/cdq/object.rb in cdq-1.0.3 vs motion/cdq/object.rb in cdq-1.0.4

- old
+ new

@@ -22,10 +22,29 @@ @@context_manager = nil @@store_manager.reset! if @@store_manager @@store_manager = nil end + # Save any data and close down the contexts and store manager. + # You should be able create a new CDQConfig object and run setup + # again to attach to a different database. However, you need to be sure + # that all activity is finished, and that any exisitng model instances + # have been deallocated. + #------------------------------------------------------------------------------ + def close + save + @@context_manager.reset! if @@context_manager + @@context_manager = nil + @@store_manager = nil + CDQConfig.default_config = nil + end + + # You can now pass in a CDQConfig object, which will be used instead of the + # one loaded from the cdq.yml file. However, the model file is loaded during + # the loading of the code - so it can only be overridden using the cdq.yml. + #------------------------------------------------------------------------------ def setup(opts = {}) + CDQConfig.default_config = opts[:config] || nil if opts[:context] contexts.push(opts[:context]) return true elsif opts[:store] stores.current = opts[:store]