Class: Valkyrie::ID

Inherits:
Object
  • Object
show all
Defined in:
lib/valkyrie/id.rb

Overview

A simple ID class to keep IDs distinguished from strings In order for an object to be queryable via joins, it needs to be added as a reference via a Valkyrie::ID rather than just a string ID.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id) ⇒ ID

Returns a new instance of ID.


9
10
11
# File 'lib/valkyrie/id.rb', line 9

def initialize(id)
  @id = id.to_s
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id


7
8
9
# File 'lib/valkyrie/id.rb', line 7

def id
  @id
end

Instance Method Details

#eql?(other) ⇒ Boolean Also known as: ==

Returns:

  • (Boolean)

27
28
29
30
# File 'lib/valkyrie/id.rb', line 27

def eql?(other)
  return string_equality(other) if Valkyrie.config.id_string_equality == true
  default_equality(other)
end

#to_sString

Returns:

  • (String)

15
16
17
# File 'lib/valkyrie/id.rb', line 15

def to_s
  to_str
end

#to_strString

Returns:

  • (String)

21
22
23
# File 'lib/valkyrie/id.rb', line 21

def to_str
  id
end