Module: ActiveTriples::Configurable
Overview
Module to include configurable class-wide properties common to Resource and RDFDatastream. It does its work at the class level, and is meant to be extended.
Define properties at the class level with:
configure base_uri: "http://oregondigital.org/resource/", repository: :default
Available properties are base_uri, rdf_label, type, and repository
Instance Method Summary collapse
- #base_uri ⇒ Object
-
#configure(options = {}) ⇒ Object
API for configuring class properties on a Resource.
- #rdf_label ⇒ Object
-
#rdf_type(value) ⇒ Object
deprecated
Deprecated.
use ‘configure type:` instead.
- #repository ⇒ Object
- #transform_type(value) ⇒ Object
- #type ⇒ Object
Instance Method Details
#base_uri ⇒ Object
16 17 18 |
# File 'lib/active_triples/configurable.rb', line 16 def base_uri nil end |
#configure(options = {}) ⇒ Object
API for configuring class properties on a Resource. This is an alternative to overriding the methods in this module.
Can configure the following values:
- base_uri (allows passing slugs to the Resource initializer
in place of fully qualified URIs)
- rdf_label (overrides default label predicates)
- type (a default rdf:type to include when initializing a
new Resource)
- repository (the target persist location to for the Resource)
configure base_uri: "http://oregondigital.org/resource/", repository: :default
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/active_triples/configurable.rb', line 54 def configure( = {}) { base_uri: [:base_uri], rdf_label: [:rdf_label], type: [:type], repository: [:repository] }.each do |name, value| if value value = self.send("transform_#{name}", value) if self.respond_to?("transform_#{name}") define_singleton_method(name) do value end end end end |
#rdf_label ⇒ Object
20 21 22 |
# File 'lib/active_triples/configurable.rb', line 20 def rdf_label nil end |
#rdf_type(value) ⇒ Object
Deprecated.
use ‘configure type:` instead.
30 31 32 33 |
# File 'lib/active_triples/configurable.rb', line 30 def rdf_type(value) Deprecation.warn Configurable, "rdf_type is deprecated and will be removed in active-fedora 8.0.0. Use configure type: instead.", caller configure type: value end |
#repository ⇒ Object
35 36 37 |
# File 'lib/active_triples/configurable.rb', line 35 def repository :parent end |
#transform_type(value) ⇒ Object
70 71 72 73 74 |
# File 'lib/active_triples/configurable.rb', line 70 def transform_type(value) RDF::URI.new(value).tap do |value| Resource.type_registry[value] = self end end |
#type ⇒ Object
24 25 26 |
# File 'lib/active_triples/configurable.rb', line 24 def type nil end |