Sha256: 4cb26564d9855829aa2e17fcdaf2898894e79ddc74ae5cf7b88d308ab00e4e2c

Contents?: true

Size: 714 Bytes

Versions: 30

Compression:

Stored size: 714 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 [Integer, nil] the neo4j id of the node if persisted or nil
      def neo_id
        _persisted_obj ? _persisted_obj.id : nil
      end

      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

30 entries across 30 versions & 1 rubygems

Version Path
activegraph-11.5.0.beta.3 lib/active_graph/shared/identity.rb
activegraph-11.5.0.beta.2 lib/active_graph/shared/identity.rb
activegraph-11.5.0.beta.1 lib/active_graph/shared/identity.rb
activegraph-11.5.0.alpha.1 lib/active_graph/shared/identity.rb
activegraph-11.4.0 lib/active_graph/shared/identity.rb
activegraph-11.3.1 lib/active_graph/shared/identity.rb
activegraph-11.3.0 lib/active_graph/shared/identity.rb
activegraph-11.2.0 lib/active_graph/shared/identity.rb
activegraph-11.1.0 lib/active_graph/shared/identity.rb
activegraph-11.1.0.beta.1 lib/active_graph/shared/identity.rb
activegraph-11.1.0.alpha.4 lib/active_graph/shared/identity.rb
activegraph-11.1.0.alpha.3 lib/active_graph/shared/identity.rb
activegraph-11.1.0.alpha.2 lib/active_graph/shared/identity.rb
activegraph-11.1.0.alpha.1 lib/active_graph/shared/identity.rb
activegraph-10.2.0.beta.1 lib/active_graph/shared/identity.rb
activegraph-11.0.2-java lib/active_graph/shared/identity.rb
activegraph-10.1.1 lib/active_graph/shared/identity.rb
activegraph-11.0.1-java lib/active_graph/shared/identity.rb
activegraph-11.0.0-java lib/active_graph/shared/identity.rb
activegraph-10.1.0 lib/active_graph/shared/identity.rb