Sha256: b1a23e6c7411109e154cfc3c09ea017b8c6037d71185c1f0635e7d419e7fc67f

Contents?: true

Size: 1.16 KB

Versions: 12

Compression:

Stored size: 1.16 KB

Contents

module Neo4j
  module Rails
    module NodePersistence
      extend TxMethods

      def initialize(attributes = nil)
        initialize_relationships
        initialize_attributes(attributes)
      end


      def create
        node = Neo4j::Node.new
        init_on_load(node)
        Neo4j::IdentityMap.add(node, self)
        init_on_create
        write_changed_relationships
        clear_relationships
        true
      end

      def update
        super
        write_changed_relationships
        clear_relationships
        true
      end

      # Reload the object from the DB
      def reload(options = nil)
        # Can't reload a none persisted node
        return self if new_record?
        clear_changes
        clear_relationships
        clear_composition_cache
        reset_attributes
        unless reload_from_database
          set_deleted_properties
          freeze
        end
        self
      end


      def reload_from_database
        Neo4j::IdentityMap.remove_node_by_id(neo_id)
        if reloaded = self.class.load_entity(neo_id)
          send(:attributes=, reloaded.attributes, false)
        end
        reloaded
      end


    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
neo4j-2.2.3-java lib/neo4j/rails/node_persistance.rb
neo4j-2.2.1-java lib/neo4j/rails/node_persistance.rb
neo4j-2.2.0-java lib/neo4j/rails/node_persistance.rb
neo4j-2.2.0.rc1-java lib/neo4j/rails/node_persistance.rb
neo4j-2.0.1-java lib/neo4j/rails/node_persistance.rb
neo4j-2.0.0-java lib/neo4j/rails/node_persistance.rb
neo4j-2.0.0.rc2-java lib/neo4j/rails/node_persistance.rb
neo4j-2.0.0.rc1-java lib/neo4j/rails/node_persistance.rb
neo4j-2.0.0.alpha.9-java lib/neo4j/rails/node_persistance.rb
neo4j-2.0.0.alpha.8-java lib/neo4j/rails/node_persistance.rb
neo4j-2.0.0.alpha.7-java lib/neo4j/rails/node_persistance.rb
neo4j-2.0.0.alpha.6-java lib/neo4j/rails/node_persistance.rb