Module: PDC::Resource::Identity
Overview
handles id, primary_key and uri of a Resource
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #as_json(options = nil) ⇒ Object
- #hash ⇒ Object
- #id ⇒ Object
- #id=(value) ⇒ Object
- #id? ⇒ Boolean
- #uri ⇒ Object
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
55 56 57 |
# File 'lib/pdc/resource/identity.rb', line 55 def ==(other) other.instance_of?(self.class) && id? && id == other.id end |
#as_json(options = nil) ⇒ Object
60 61 62 |
# File 'lib/pdc/resource/identity.rb', line 60 def as_json( = nil) attributes.as_json() end |
#hash ⇒ Object
51 52 53 |
# File 'lib/pdc/resource/identity.rb', line 51 def hash id.hash end |
#id ⇒ Object
43 44 45 |
# File 'lib/pdc/resource/identity.rb', line 43 def id attributes[primary_key] end |
#id=(value) ⇒ Object
47 48 49 |
# File 'lib/pdc/resource/identity.rb', line 47 def id=(value) attributes[primary_key] = value if value.present? end |
#id? ⇒ Boolean
39 40 41 |
# File 'lib/pdc/resource/identity.rb', line 39 def id? attributes[primary_key].present? end |