# File lib/pdc/resource/identity.rb, line 72 def primary_key self.class.primary_key end
module PDC::Resource::Identity
handles id, primary_key
and uri of a Resource
Public Instance Methods
==(other)
click to toggle source
# File lib/pdc/resource/identity.rb, line 55 def ==(other) other.instance_of?(self.class) && id? && id == other.id end
Also aliased as: eql?
as_json(options = nil)
click to toggle source
# File lib/pdc/resource/identity.rb, line 60 def as_json(options = nil) attributes.as_json(options) end
hash()
click to toggle source
# File lib/pdc/resource/identity.rb, line 51 def hash id.hash end
id()
click to toggle source
# File lib/pdc/resource/identity.rb, line 43 def id attributes[primary_key] end
id=(value)
click to toggle source
# File lib/pdc/resource/identity.rb, line 47 def id=(value) attributes[primary_key] = value if value.present? end
id?()
click to toggle source
# File lib/pdc/resource/identity.rb, line 39 def id? attributes[primary_key].present? end
uri()
click to toggle source
# File lib/pdc/resource/identity.rb, line 64 def uri Path.new(self.class.uri.to_s, attributes).expanded end
Private Instance Methods
primary_key()
click to toggle source
helper method so that primary_key
can be called directly from an instance