lib/active_rdf/objectmanager/namespace.rb in activerdf-1.6.6 vs lib/active_rdf/objectmanager/namespace.rb in activerdf-1.6.8
- old
+ new
@@ -30,11 +30,11 @@
def method_missing(method, *args)
Namespace.lookup(self.to_s.downcase.to_sym, method)
end
def const_missing(klass)
- Namespace.lookup(self.to_s.downcase.to_sym, klass)
+ ObjectManager.construct_class(Namespace.lookup(self.to_s.downcase.to_sym, klass))
end
# make some builtin methods private because lookup doesn't work otherwise
# on e.g. RDF::type and FOAF::name
[:type, :name, :id].each {|m| private(m) }
@@ -78,14 +78,12 @@
@@inverted_namespaces[nonlocal]
end
# returns local-part of URI
def self.localname(resource)
+ raise ActiveRdfError, "localname called on something that doesn't respond to uri" unless resource.respond_to? :uri
# get string representation of resource uri
- uri = case resource
- when RDFS::Resource: resource.uri
- else resource.to_s
- end
+ uri = resource.uri
delimiter = uri.rindex(/#|\//)
if delimiter.nil? or delimiter == uri.size-1
uri
else