lib/active_graph/shared/callbacks.rb in activegraph-10.0.0.pre.beta.3 vs lib/active_graph/shared/callbacks.rb in activegraph-10.0.0.pre.beta.4

- old
+ new

@@ -18,20 +18,18 @@ def initialize(args = nil) run_callbacks(:initialize) { super } end def destroy #:nodoc: - tx = ActiveGraph::Base.new_transaction - tx.root.after_commit { run_callbacks(:destroy_commit) {} } - run_callbacks(:destroy) { super } + ActiveGraph::Base.validating_transaction do |tx| + tx.after_commit { run_callbacks(:destroy_commit) {} } + run_callbacks(:destroy) { super } + end rescue @_deleted = false @attributes = @attributes.dup - tx.mark_failed if tx raise - ensure - tx.close if tx end def touch #:nodoc: run_callbacks(:touch) { super } end @@ -49,18 +47,18 @@ def create_or_update #:nodoc: run_callbacks(:save) { super } end def create_model #:nodoc: - self.class.run_transaction do |tx| - tx.root.after_commit { run_callbacks(:create_commit) {} } + ActiveGraph::Base.transaction do |tx| + tx.after_commit { run_callbacks(:create_commit) {} } run_callbacks(:create) { super } end end def update_model(*) #:nodoc: - self.class.run_transaction do |tx| - tx.root.after_commit { run_callbacks(:update_commit) {} } + ActiveGraph::Base.transaction do |tx| + tx.after_commit { run_callbacks(:update_commit) {} } run_callbacks(:update) { super } end end end end