Class: RDF::Repository
- Inherits:
-
Object
- Object
- RDF::Repository
- Includes:
- Countable, Durable, Enumerable, Mutable, Queryable
- Defined in:
- lib/rdf/repository.rb
Overview
An RDF repository.
Defined Under Namespace
Modules: Implementation
Instance Attribute Summary (collapse)
-
- (Hash{Symbol => Object}) options
readonly
Returns the options passed to this repository when it was constructed.
-
- (String) title
readonly
Returns the title of this repository.
-
- (URI) uri
(also: #url)
readonly
Returns the URI of this repository.
Class Method Summary (collapse)
-
+ load(filenames, options = {}) {|repository| ... }
Loads one or more RDF files into a new transient in-memory repository.
Instance Method Summary (collapse)
-
- (RDF::Transaction) begin_transaction(context)
protected
Begins a new transaction.
-
- commit_transaction(tx)
protected
Commits the given transaction.
-
- (Repository) initialize(options = {}) {|repository| ... }
constructor
Initializes this repository instance.
-
- (String) inspect
Returns a developer-friendly representation of this object.
-
- inspect!
Outputs a developer-friendly representation of this object to
stderr. -
- rollback_transaction(tx)
protected
Rolls back the given transaction.
-
- (Boolean) supports?(feature)
Returns
trueif this repository supports the givenfeature. -
- transaction(context = nil) {|tx| ... }
(also: #transact)
Executes the given block in a transaction.
Methods included from Durable
Methods included from Util::Aliasing::LateBound
Methods included from Mutable
#<<, #clear, #delete, #delete_statement, #delete_statements, #immutable?, #insert, #load, #mutable?, #update
Methods included from Writable
#<<, #insert, #insert_graph, #insert_reader, #insert_statement, #insert_statements, #writable?
Methods included from Readable
Methods included from Queryable
#first, #first_literal, #first_object, #first_predicate, #first_subject, #first_value, #query, #query_execute, #query_pattern
Methods included from Enumerable
#contexts, #dump, #each_context, #each_graph, #each_object, #each_predicate, #each_quad, #each_statement, #each_subject, #each_triple, #enum_context, #enum_graph, #enum_object, #enum_predicate, #enum_quad, #enum_statement, #enum_subject, #enum_triple, #has_context?, #has_object?, #has_predicate?, #has_quad?, #has_statement?, #has_subject?, #has_triple?, #objects, #predicates, #quads, #statements, #subjects, #to_a, #to_hash, #to_set, #triples
Methods included from Countable
Constructor Details
- (Repository) initialize(options = {}) {|repository| ... }
Initializes this repository instance.
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/rdf/repository.rb', line 99 def initialize( = {}, &block) = .dup @uri = .delete(:uri) @title = .delete(:title) # Provide a default in-memory implementation: send(:extend, Implementation) if self.class.equal?(RDF::Repository) if block_given? case block.arity when 1 then block.call(self) else instance_eval(&block) end end end |
Instance Attribute Details
- (Hash{Symbol => Object}) options (readonly)
Returns the options passed to this repository when it was constructed.
54 55 56 |
# File 'lib/rdf/repository.rb', line 54 def end |
- (String) title (readonly)
Returns the title of this repository.
67 68 69 |
# File 'lib/rdf/repository.rb', line 67 def title @title end |
Class Method Details
+ load(filenames, options = {}) {|repository| ... }
This method returns an undefined value.
Loads one or more RDF files into a new transient in-memory repository.
76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/rdf/repository.rb', line 76 def self.load(filenames, = {}, &block) self.new() do |repository| [filenames].flatten.each do |filename| repository.load(filename, ) end if block_given? case block.arity when 1 then block.call(repository) else repository.instance_eval(&block) end end end end |
Instance Method Details
- (RDF::Transaction) begin_transaction(context) (protected)
Begins a new transaction.
Subclasses implementing transaction-capable storage adapters may wish to override this method in order to begin a transaction against the underlying storage.
186 187 188 |
# File 'lib/rdf/repository.rb', line 186 def begin_transaction(context) RDF::Transaction.new(:context => context) end |
- commit_transaction(tx) (protected)
This method returns an undefined value.
Commits the given transaction.
Subclasses implementing transaction-capable storage adapters may wish to override this method in order to commit the given transaction to the underlying storage.
214 215 216 |
# File 'lib/rdf/repository.rb', line 214 def commit_transaction(tx) tx.execute(self) end |
- (String) inspect
Returns a developer-friendly representation of this object.
129 130 131 |
# File 'lib/rdf/repository.rb', line 129 def inspect sprintf("#<%s:%#0x(%s)>", self.class.name, __id__, uri.to_s) end |
- inspect!
This method returns an undefined value.
Outputs a developer-friendly representation of this object to
stderr.
138 139 140 141 |
# File 'lib/rdf/repository.rb', line 138 def inspect! each_statement { |statement| statement.inspect! } nil end |
- rollback_transaction(tx) (protected)
This method returns an undefined value.
Rolls back the given transaction.
Subclasses implementing transaction-capable storage adapters may wish to override this method in order to roll back the given transaction in the underlying storage.
200 201 202 |
# File 'lib/rdf/repository.rb', line 200 def rollback_transaction(tx) # nothing to do end |
- (Boolean) supports?(feature)
Returns true if this repository supports the given feature.
121 122 123 |
# File 'lib/rdf/repository.rb', line 121 def supports?(feature) false end |
- transaction(context = nil) {|tx| ... } Also known as: transact
This method returns an undefined value.
Executes the given block in a transaction.
158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
# File 'lib/rdf/repository.rb', line 158 def transaction(context = nil, &block) tx = begin_transaction(context) begin case block.arity when 1 then block.call(tx) else tx.instance_eval(&block) end rescue => error rollback_transaction(tx) raise error end commit_transaction(tx) self end |