Class: Valkyrie::ID
- Inherits:
-
Object
- Object
- Valkyrie::ID
- 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
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Instance Method Summary collapse
- #eql?(other) ⇒ Boolean (also: #==)
-
#initialize(id) ⇒ ID
constructor
A new instance of ID.
- #to_s ⇒ Object
-
#to_uri ⇒ Object
deprecated
Deprecated.
Please use uri_for instead
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
#id ⇒ Object (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: ==
19 20 21 |
# File 'lib/valkyrie/id.rb', line 19 def eql?(other) other.class == self.class && other.state == state end |
#to_s ⇒ Object
13 14 15 |
# File 'lib/valkyrie/id.rb', line 13 def to_s id end |
#to_uri ⇒ Object
Deprecated.
Please use uri_for instead
25 26 27 28 29 30 |
# File 'lib/valkyrie/id.rb', line 25 def to_uri return RDF::Literal.new(id.to_s, datatype: RDF::URI("http://example.com/valkyrie_id")) if id.to_s.include?("://") warn "[DEPRECATION] `to_uri` is deprecated and will be removed in the next major release. " \ "Called from #{Gem.location_of_caller.join(':')}" ::RDF::URI(ActiveFedora::Base.id_to_uri(id)) end |