Module: ActiveRDF::NamespaceProxy

Defined in:
lib/active_rdf/objectmanager/namespace.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object

catch FOAF::name.



120
121
122
123
# File 'lib/active_rdf/objectmanager/namespace.rb', line 120

def method_missing(method, *args)
  @resources ||={}  # resource cache
  @resources[method] ||= Namespace.lookup(@prefix, method)
end

Instance Attribute Details

#klassesObject

Returns the value of attribute klasses.



108
109
110
# File 'lib/active_rdf/objectmanager/namespace.rb', line 108

def klasses
  @klasses
end

#prefixObject

Returns the value of attribute prefix.



108
109
110
# File 'lib/active_rdf/objectmanager/namespace.rb', line 108

def prefix
  @prefix
end

#resourcesObject

Returns the value of attribute resources.



108
109
110
# File 'lib/active_rdf/objectmanager/namespace.rb', line 108

def resources
  @resources
end

Class Method Details

.extend_object(obj) ⇒ Object



110
111
112
113
114
115
116
117
# File 'lib/active_rdf/objectmanager/namespace.rb', line 110

def NamespaceProxy.extend_object(obj)
  # make some builtin methods private because lookup doesn't work otherwise
  # on e.g. RDF::type and FOAF::name
  class << obj
    [:type, :name, :id].each {|m| private(m) if respond_to?(m)}
  end
  super
end

Instance Method Details

#const_missing(klass) ⇒ Object

catch FOAF::Person



126
127
128
129
130
# File 'lib/active_rdf/objectmanager/namespace.rb', line 126

def const_missing(klass)
ActiveRdfLogger::log_info(self) { "Const missing on Namespace #{klass}" }
  @klasses ||={}  # class cache
  @klasses[klass] ||= ObjectManager.construct_class(Namespace.lookup(@prefix, klass))
end