Sha256: f6e6eec9819bb98239239749130c4eafd0fb73014d18338b9f0ed2d662def781

Contents?: true

Size: 1.23 KB

Versions: 113

Compression:

Stored size: 1.23 KB

Contents

module Neo4j::Shared
  class DeclaredProperty
    # None of these methods interact with the database. They only keep track of property settings in models.
    # It could (should?) handle the actual indexing/constraining, but that's TBD.
    module Index
      def index_or_constraint?
        index?(:exact) || constraint?(:unique)
      end

      def index?(type = :exact)
        options.key?(:index) && options[:index] == type
      end

      def constraint?(type = :unique)
        options.key?(:constraint) && options[:constraint] == type
      end

      def index!(type = :exact)
        fail Neo4j::InvalidPropertyOptionsError, "Can't set index on constrainted property #{name} (constraints get indexes automatically)" if constraint?(:unique)
        options[:index] = type
      end

      def constraint!(type = :unique)
        fail Neo4j::InvalidPropertyOptionsError, "Can't set constraint on indexed property #{name} (constraints get indexes automatically)" if index?(:exact)
        options[:constraint] = type
      end

      def unindex!(type = :exact)
        options.delete(:index) if index?(type)
      end

      def unconstraint!(type = :unique)
        options.delete(:constraint) if constraint?(type)
      end
    end
  end
end

Version data entries

113 entries across 113 versions & 3 rubygems

Version Path
neo4j-8.0.0.rc.1 lib/neo4j/shared/declared_property/index.rb
neo4j-8.0.0.alpha.12 lib/neo4j/shared/declared_property/index.rb
neo4j-7.2.3 lib/neo4j/shared/declared_property/index.rb
neo4j-8.0.0.alpha.11 lib/neo4j/shared/declared_property/index.rb
neo4j-7.2.2 lib/neo4j/shared/declared_property/index.rb
neo4j-7.1.4 lib/neo4j/shared/declared_property/index.rb
neo4j-7.0.16 lib/neo4j/shared/declared_property/index.rb
neo4j-7.2.1 lib/neo4j/shared/declared_property/index.rb
neo4j-8.0.0.alpha.10 lib/neo4j/shared/declared_property/index.rb
neo4j-8.0.0.alpha.9 lib/neo4j/shared/declared_property/index.rb
neo4j-8.0.0.alpha.8 lib/neo4j/shared/declared_property/index.rb
neo4j-8.0.0.alpha.7 lib/neo4j/shared/declared_property/index.rb
neo4j_legacy-7.2.0.2 lib/neo4j/shared/declared_property/index.rb
neo4j_legacy-7.2.0.1 lib/neo4j/shared/declared_property/index.rb
neo4j-8.0.0.alpha.6 lib/neo4j/shared/declared_property/index.rb
neo4j-8.0.0.alpha.5 lib/neo4j/shared/declared_property/index.rb
neo4j-8.0.0.alpha.4 lib/neo4j/shared/declared_property/index.rb
neo4j-7.2.0 lib/neo4j/shared/declared_property/index.rb
neo4j-7.1.3 lib/neo4j/shared/declared_property/index.rb
neo4j-7.0.15 lib/neo4j/shared/declared_property/index.rb