Sha256: ce07d9ce9577f9ebe234005bdbf3f93589efcc7467180eb75fff60a0e6e305b4

Contents?: true

Size: 718 Bytes

Versions: 8

Compression:

Stored size: 718 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.neo_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

8 entries across 8 versions & 1 rubygems

Version Path
activegraph-10.0.0.pre.beta.8 lib/active_graph/shared/identity.rb
activegraph-10.0.0.pre.beta.7 lib/active_graph/shared/identity.rb
activegraph-10.0.0.pre.beta.6 lib/active_graph/shared/identity.rb
activegraph-10.0.0.pre.beta.5 lib/active_graph/shared/identity.rb
activegraph-10.0.0.pre.beta.4 lib/active_graph/shared/identity.rb
activegraph-10.0.0.pre.beta.3 lib/active_graph/shared/identity.rb
activegraph-10.0.0.pre.beta.2 lib/active_graph/shared/identity.rb
activegraph-10.0.0.pre.beta.1 lib/active_graph/shared/identity.rb