Sha256: 8542d99d740ab8b251113e49f113919bff189bae675a7f301caa688de94f26f0

Contents?: true

Size: 735 Bytes

Versions: 5

Compression:

Stored size: 735 Bytes

Contents

module ActiveGraph
  module Shared
    module Identity
      def ==(other)
        other.class == self.class && other.id == id
      end

      alias eql? ==

      # Returns an Enumerable of all (primary) key attributes
      # or nil if model.persisted? is false
      def to_key
        _persisted_obj ? [id] : nil
      end

      # @return [String, nil] the neo4j id of the node if persisted or nil
      def element_id
        _persisted_obj&.element_id
      end

      alias neo_id element_id

      def id
        if self.class.id_property_name
          send(self.class.id_property_name)
        else
          # Relationship
          neo_id
        end
      end

      def hash
        id.hash
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
activegraph-12.0.0.beta.5 lib/active_graph/shared/identity.rb
activegraph-12.0.0.beta.4 lib/active_graph/shared/identity.rb
activegraph-12.0.0.beta.3 lib/active_graph/shared/identity.rb
activegraph-12.0.0.beta.2 lib/active_graph/shared/identity.rb
activegraph-12.0.0.beta.1 lib/active_graph/shared/identity.rb