lib/neo4j/shared/callbacks.rb in neo4j-8.0.18 vs lib/neo4j/shared/callbacks.rb in neo4j-8.1.0.rc.1

- old
+ new

@@ -9,19 +9,21 @@ included do include ActiveModel::Validations::Callbacks # after_find is triggered by the `find` method defined in lib/neo4j/active_node/id_property.rb define_model_callbacks :initialize, :find, only: :after + define_model_callbacks :create_commit, :update_commit, :destroy_commit, only: :after define_model_callbacks :save, :create, :update, :destroy, :touch end def initialize(args = nil) run_callbacks(:initialize) { super } end def destroy #:nodoc: tx = Neo4j::ActiveBase.new_transaction + tx.root.after_commit { run_callbacks(:destroy_commit) {} } run_callbacks(:destroy) { super } rescue @_deleted = false @attributes = @attributes.dup tx.mark_failed if tx @@ -47,16 +49,18 @@ def create_or_update #:nodoc: run_callbacks(:save) { super } end def create_model #:nodoc: - self.class.run_transaction do + self.class.run_transaction do |tx| + tx.root.after_commit { run_callbacks(:create_commit) {} } run_callbacks(:create) { super } end end def update_model(*) #:nodoc: - self.class.run_transaction do + self.class.run_transaction do |tx| + tx.root.after_commit { run_callbacks(:update_commit) {} } run_callbacks(:update) { super } end end end end