Module: ActiveFedora::Identifiable::ClassMethods

Defined in:
lib/active_fedora/identifiable.rb

Instance Method Summary collapse

Instance Method Details

#from_uri(uri, _) ⇒ Object

Provides the common interface for ActiveTriples::Identifiable



70
71
72
73
74
# File 'lib/active_fedora/identifiable.rb', line 70

def from_uri(uri, _)
  find(uri_to_id(uri))
rescue ActiveFedora::ObjectNotFoundError, Ldp::Gone
  ActiveTriples::Resource.new(uri)
end

#id_to_uri(id) ⇒ Object

Transforms an id into a uri if translate_id_to_uri is set it uses that proc, otherwise just the default



57
58
59
# File 'lib/active_fedora/identifiable.rb', line 57

def id_to_uri(id)
  translate_id_to_uri.call(id)
end

#uri_to_id(uri) ⇒ Object

Transforms a uri into an id if translate_uri_to_id is set it uses that proc, otherwise just the default



64
65
66
# File 'lib/active_fedora/identifiable.rb', line 64

def uri_to_id(uri)
  translate_uri_to_id.call(uri)
end