class Fauna::Ref

A Ref.

Reference: FaunaDB Special Types

Attributes

class_[RW]

The raw attributes of ref.

database[RW]

The raw attributes of ref.

id[RW]

The raw attributes of ref.

Public Class Methods

new('prydain', Native.databases) click to toggle source

Creates a Ref object.

id: A string. class_: A Ref. database: A Ref.

# File lib/fauna/objects.rb, line 19
def initialize(id, class_ = nil, database = nil)
  fail ArgumentError.new 'id cannot be nil' if id.nil?

  @id = id
  @class_ = class_ unless class_.nil?
  @database = database unless database.nil?
end

Public Instance Methods

==(other) click to toggle source

Returns true if other is a Ref and contains the same value.

# File lib/fauna/objects.rb, line 43
def ==(other)
  return false unless other.is_a? Ref
  id == other.id && class_ == other.class_ && database == other.database
end
Also aliased as: eql?
eql?(other)
Alias for: ==
to_hash() click to toggle source

Converts the Ref in Hash form.

# File lib/fauna/objects.rb, line 35
def to_hash
  ref = { id: id }
  ref[:class] = class_ unless class_.nil?
  ref[:database] = database unless database.nil?
  { :@ref => ref }
end
to_s() click to toggle source

Converts the Ref to a string

# File lib/fauna/objects.rb, line 28
def to_s
  cls = class_.nil? ? '' : ",class=#{class_.to_s}"
  db = database.nil? ? '' : ",database=#{database.to_s}"
  "Ref(id=#{id}#{cls}#{db})"
end