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
19 def initialize(id, class_ = nil, database = nil)
20   fail ArgumentError.new 'id cannot be nil' if id.nil?
21 
22   @id = id
23   @class_ = class_ unless class_.nil?
24   @database = database unless database.nil?
25 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
43 def ==(other)
44   return false unless other.is_a? Ref
45   id == other.id && class_ == other.class_ && database == other.database
46 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
35 def to_hash
36   ref = { id: id }
37   ref[:class] = class_ unless class_.nil?
38   ref[:database] = database unless database.nil?
39   { :@ref => ref }
40 end
to_s() click to toggle source

Converts the Ref to a string

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