Class: RDF::URI
- Inherits:
-
Object
- Object
- RDF::URI
- Includes:
- RDFObjects::Resource
- Defined in:
- lib/rdf/rdfobjects.rb,
lib/rdf/rdfobjects/uri.rb
Instance Attribute Summary
Attributes included from RDFObjects::Resource
Class Method Summary collapse
- .cache ⇒ RDF::Util::Cache
-
.intern(str) ⇒ Object
Don’t freeze the URIs.
Instance Method Summary collapse
Methods included from RDFObjects::Resource
#[], #[]=, #assert, #cast_as_typed_object, #clear, #method_missing, #object_of, #predicates, #properties, #push, #relate, #remove, #statements, #to_ntriples, #type, #type=
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class RDF::RDFObjects::Resource
Class Method Details
.cache ⇒ RDF::Util::Cache
6 7 8 9 10 |
# File 'lib/rdf/rdfobjects/uri.rb', line 6 def self.cache require 'rdf/util/cache' unless defined?(::RDF::Util::Cache) @cache ||= {} @cache[@graph] ||= RDF::Util::Cache.new(CACHE_SIZE) end |
.intern(str) ⇒ Object
Don’t freeze the URIs. Keep an eye on this, since, presumably, URIs are being frozen for a reason. However, we cannot add graphs to frozen objects and the ObjectStore complicates things.
16 17 18 |
# File 'lib/rdf/rdfobjects.rb', line 16 def self.intern(str) (cache[str = str.to_s] ||= self.new(str)) end |
Instance Method Details
#graph=(graph) ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/rdf/rdfobjects/uri.rb', line 16 def graph=(graph) raise ArgumentError unless graph.is_a?(::RDF::Graph) if !self.frozen? && graph != self.graph @graph = graph elsif self.frozen? && graph != self.graph new_uri = self.dup self = new_uri @graph = graph end end |