Sha256: 2a02d17f6b3ee3becd39f08746270271abe148ed9994f67c5c4376f549379ee1

Contents?: true

Size: 603 Bytes

Versions: 3

Compression:

Stored size: 603 Bytes

Contents

# frozen_string_literal: true

module Redgraph
  class Node
    include Util

    attr_accessor :id, :label, :properties

    def initialize(label: nil, properties: nil, id: nil)
      @id = id
      @label = label
      @properties = (properties || {}).with_indifferent_access
    end

    def persisted?
      id.present?
    end

    def ==(other)
      super || other.instance_of?(self.class) && !id.nil? && other.id == id
    end

    def to_query_string(item_alias: 'node')
      _label = ":#{label}" if label
      "(#{item_alias}#{_label} #{properties_to_string(properties)})"
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
redgraph-0.2.1 lib/redgraph/node.rb
redgraph-0.2.0 lib/redgraph/node.rb
redgraph-0.1.4 lib/redgraph/node.rb