Module: ActiveFedora::Rdf::Configurable

Extended by:
Deprecation
Included in:
List, Resource
Defined in:
lib/active_fedora/rdf/configurable.rb

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: :parent

Available properties are base_uri, rdf_label, type, and repository

Instance Method Summary collapse

Instance Method Details

#base_uriObject



14
15
16
# File 'lib/active_fedora/rdf/configurable.rb', line 14

def base_uri
  nil
end

#configure(options = {}) ⇒ Object

API method for configuring class properties an RDF Resource may need. This is an alternative to overriding the methods extended with this module.



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/active_fedora/rdf/configurable.rb', line 37

def configure(options = {})
  {
    base_uri: options[:base_uri],
    rdf_label: options[:rdf_label],
    type: options[:type],
    repository: options[: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_labelObject



18
19
20
# File 'lib/active_fedora/rdf/configurable.rb', line 18

def rdf_label
  nil
end

#rdf_type(value) ⇒ Object



26
27
28
29
# File 'lib/active_fedora/rdf/configurable.rb', line 26

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

#repositoryObject



31
32
33
# File 'lib/active_fedora/rdf/configurable.rb', line 31

def repository
  :parent
end

#transform_type(value) ⇒ Object



53
54
55
56
57
# File 'lib/active_fedora/rdf/configurable.rb', line 53

def transform_type(value)
  RDF::URI.new(value).tap do |value|
    Resource.type_registry[value] = self
  end
end

#typeObject



22
23
24
# File 'lib/active_fedora/rdf/configurable.rb', line 22

def type
  nil
end