Sha256: 7b69203ae9824714df17d2bd8fccf786f726f058b932336ac427aac90c0e300c

Contents?: true

Size: 999 Bytes

Versions: 6

Compression:

Stored size: 999 Bytes

Contents

module Neo4j
  module ActiveNode
    module Dependent
      module AssociationMethods
        def add_destroy_callbacks(model)
          return if dependent.nil?
          # Bound value for procs
          assoc = self

          fn = case dependent
               when :delete
                 proc { |o| o.send("#{assoc.name}_query_proxy").delete_all }
               when :delete_orphans
                 proc { |o| o.as(:self).unique_nodes(assoc, :self, :n, :other_rel).query.delete(:n, :other_rel).exec }
               when :destroy
                 proc { |o| o.send("#{assoc.name}_query_proxy").each_for_destruction(o) { |node| node.destroy } }
               when :destroy_orphans
                 proc { |o| o.as(:self).unique_nodes(assoc, :self, :n, :other_rel).each_for_destruction(o) { |node| node.destroy } }
               else
                 fail "Unknown dependent option #{dependent}"
               end

          model.before_destroy fn
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
neo4j-4.1.5 lib/neo4j/active_node/dependent/association_methods.rb
neo4j-4.1.4 lib/neo4j/active_node/dependent/association_methods.rb
neo4j-4.1.3 lib/neo4j/active_node/dependent/association_methods.rb
neo4j-4.1.2 lib/neo4j/active_node/dependent/association_methods.rb
neo4j-4.1.1 lib/neo4j/active_node/dependent/association_methods.rb
neo4j-4.1.0 lib/neo4j/active_node/dependent/association_methods.rb