Sha256: 5c7a94d109fc16db30ea107c503778f3821b77b4954a0c41214f0fcf3deea2a5

Contents?: true

Size: 1.24 KB

Versions: 25

Compression:

Stored size: 1.24 KB

Contents

module Neo4j

  module Migrations

    # Overrides the init_on_load method so that it will check if any migration is needed.
    # The init_on_create method is also overridden so that it sets the version to the latest migration number
    # when a new node is created.
    #
    # Migration will take place if needed when the node is loaded.
    #
    module LazyNodeMixin
      extend ActiveSupport::Concern

      included do
        extend Neo4j::Migrations::ClassMethods
      end

      module ClassMethods
        # Remote all migration and set migrate_to = nil
        # Does not change the version of nodes.
        def reset_migrations!
          @migrations = nil
          @migrate_to = nil
        end
      end

      def migrate!
        self.class._migrate!(self._java_node, self)
      end

      def init_on_create(*)
        super
        # set the db version to the current
        self[:_db_version] = self.class.migrate_to
      end

      def init_on_load(*) # :nodoc:
        super
        migrate!
        # this if for Neo4j::Rails::Model which keeps the properties in this variable
        @properties.clear if instance_variable_defined? :@properties
      end

      def db_version
        self[:_db_version]
      end
    end

  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
neo4j-2.0.0.alpha.4-java lib/neo4j/migrations/lazy_node_mixin.rb
neo4j-2.0.0.alpha.3-java lib/neo4j/migrations/lazy_node_mixin.rb
neo4j-1.3.1-java lib/neo4j/migrations/lazy_node_mixin.rb
neo4j-1.3.0-java lib/neo4j/migrations/lazy_node_mixin.rb
neo4j-1.2.6-java lib/neo4j/migrations/lazy_node_mixin.rb
neo4j-1.2.5-java lib/neo4j/migrations/lazy_node_mixin.rb
neo4j-1.2.4-java lib/neo4j/migrations/lazy_node_mixin.rb
neo4j-1.2.3-java lib/neo4j/migrations/lazy_node_mixin.rb
neo4j-1.2.2-java lib/neo4j/migrations/lazy_node_mixin.rb
neo4j-1.2.1-java lib/neo4j/migrations/lazy_node_mixin.rb
neo4j-1.2.0-java lib/neo4j/migrations/lazy_node_mixin.rb
neo4j-1.1.4-java lib/neo4j/migrations/lazy_node_mixin.rb
neo4j-1.1.3-java lib/neo4j/migrations/lazy_node_mixin.rb
neo4j-1.1.2-java lib/neo4j/migrations/lazy_node_mixin.rb
neo4j-1.1.1-java lib/neo4j/migrations/lazy_node_mixin.rb
neo4j-1.1.0-java lib/neo4j/migrations/lazy_node_mixin.rb
neo4j-1.1.0.beta.3-java lib/neo4j/migrations/lazy_node_mixin.rb
neo4j-1.1.0.beta.2-java lib/neo4j/migrations/lazy_node_mixin.rb
neo4j-1.1.0.beta.1-java lib/neo4j/migrations/lazy_node_mixin.rb
neo4j-1.0.0-java lib/neo4j/migrations/lazy_node_mixin.rb