Sha256: 32587ae6ae973b1f652155201f6c237eb6b3320326119b834559cf843ee98947

Contents?: true

Size: 949 Bytes

Versions: 9

Compression:

Stored size: 949 Bytes

Contents

module Neo4j::Shared
  # This module adds the `serialize` class method. It lets you store hashes and arrays in Neo4j properties.
  # Be aware that you won't be able to search within serialized properties and stuff use indexes. If you do a regex search for portion of a string
  # property, the search happens in Cypher and you may take a performance hit.
  #
  # See type_converters.rb for the serialization process.
  module SerializedProperties
    extend ActiveSupport::Concern

    def serialized_properties
      self.class.serialized_properties
    end

    def serializable_hash(*args)
      super.merge(id: id)
    end

    module ClassMethods
      def serialized_properties
        @serialize || {}
      end

      def serialized_properties=(serialize_hash)
        @serialize = serialize_hash.clone
      end

      def serialize(name, coder = JSON)
        @serialize ||= {}
        @serialize[name] = coder
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
neo4j-4.1.5 lib/neo4j/shared/serialized_properties.rb
neo4j-4.1.4 lib/neo4j/shared/serialized_properties.rb
neo4j-4.1.3 lib/neo4j/shared/serialized_properties.rb
neo4j-4.1.2 lib/neo4j/shared/serialized_properties.rb
neo4j-4.1.1 lib/neo4j/shared/serialized_properties.rb
neo4j-4.1.0 lib/neo4j/shared/serialized_properties.rb
neo4j-4.0.0 lib/neo4j/shared/serialized_properties.rb
neo4j-4.0.0.rc.4 lib/neo4j/shared/serialized_properties.rb
neo4j-4.0.0.rc.3 lib/neo4j/shared/serialized_properties.rb