Module: ActsAsRdf::ClassMethods

Defined in:
lib/acts_as_rdf.rb

Overview

This acts_as extension provides the capabilities for rendering rdf

Instance Method Summary collapse

Instance Method Details

#acts_as_rdf(options = {}) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/acts_as_rdf.rb', line 14

def acts_as_rdf(options = {})
  configuration = {
      :prefixes      => {'rdf'  => RDF, 'rdfs' => RDF::RDFS, 'xsd'  => 'http://www.w3.org/2001/XMLSchema#', 'owl'  => RDF::OWL},
      :ontology_name => 'ontology'
  }
  configuration.update(options) if options.is_a?(Hash)

  class_eval <<-EOV
    include ActsAsRdf::InstanceMethods

    def acts_as_rdf_class
      self.class
    end

    def get_prefixes
      '#{configuration[:prefixes]}'
    end

    def get_ontology_name
      '#{configuration[:ontology_name]}'
    end

    def self.to_rdfs(request = nil, format = :rdfxml)
      new.to_rdfs(request, format)
    end
  EOV
end