Module: ActiveFedora::Core::ClassMethods
- Defined in:
- lib/active_fedora/core.rb
Constant Summary collapse
- SLASH =
'/'.freeze
Instance Method Summary collapse
-
#from_uri(uri, _) ⇒ Object
Provides the common interface for ActiveTriples::Identifiable.
- #generated_association_methods ⇒ Object
-
#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.
-
#to_class_uri(attrs = {}) ⇒ Object
Returns a suitable uri object for :has_model Should reverse Model#from_class_uri TODO this is a poorly named method.
-
#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.
Instance Method Details
#from_uri(uri, _) ⇒ Object
Provides the common interface for ActiveTriples::Identifiable
160 161 162 163 164 165 166 |
# File 'lib/active_fedora/core.rb', line 160 def from_uri(uri,_) begin self.find(uri_to_id(uri)) rescue ActiveFedora::ObjectNotFoundError, Ldp::Gone ActiveTriples::Resource.new(uri) end end |
#generated_association_methods ⇒ Object
129 130 131 132 133 134 135 |
# File 'lib/active_fedora/core.rb', line 129 def generated_association_methods @generated_association_methods ||= begin mod = const_set(:GeneratedAssociationMethods, Module.new) include mod mod end 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
147 148 149 |
# File 'lib/active_fedora/core.rb', line 147 def id_to_uri(id) translate_id_to_uri.call(id) end |
#to_class_uri(attrs = {}) ⇒ Object
Returns a suitable uri object for :has_model Should reverse Model#from_class_uri TODO this is a poorly named method
140 141 142 |
# File 'lib/active_fedora/core.rb', line 140 def to_class_uri(attrs = {}) name 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
154 155 156 |
# File 'lib/active_fedora/core.rb', line 154 def uri_to_id(uri) translate_uri_to_id.call(uri) end |