Class: RDF::Changeset
Overview
When applying a Changeset, deletes are resolved before inserts.
An RDF changeset that can be applied to an Mutable.
Changesets consist of a sequence of RDF statements to delete from and a sequence of RDF statements to insert into a target dataset.
Instance Attribute Summary collapse
-
#deletes ⇒ RDF::Enumerable
readonly
RDF statements to delete when applied.
-
#inserts ⇒ RDF::Enumerable
readonly
RDF statements to insert when applied.
-
#options ⇒ Hash{Symbol => Object}
readonly
Any additional options for this changeset.
Class Method Summary collapse
-
.apply(mutable, options = {}) {|changes| ... } ⇒ void
Applies a changeset to the given mutable RDF::Enumerable .
Instance Method Summary collapse
-
#apply(mutable, options = {}) ⇒ void
Applies this changeset to the given mutable RDF::Enumerable.
-
#empty? ⇒ Boolean
‘true` iff inserts and deletes are both empty.
-
#initialize(insert: [], delete: []) {|changes| ... } ⇒ Changeset
constructor
Initializes this changeset.
-
#inspect ⇒ String
Returns a developer-friendly representation of this changeset.
-
#inspect! ⇒ void
Outputs a developer-friendly representation of this changeset to ‘stderr`.
-
#readable? ⇒ Boolean
Returns ‘false` to indicate that this changeset is append-only.
Methods included from Mutable
#<<, #apply_changeset, #clear, #delete, #delete_insert, #immutable?, #insert, #load, #method_missing, #mutable?, #respond_to_missing?, #snapshot, #update
Methods included from Util::Aliasing::LateBound
Methods included from Writable
Constructor Details
#initialize(insert: [], delete: []) {|changes| ... } ⇒ Changeset
Initializes this changeset.
73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/rdf/changeset.rb', line 73 def initialize(insert: [], delete: [], &block) @inserts = insert @deletes = delete @inserts.extend(RDF::Enumerable) unless @inserts.kind_of?(RDF::Enumerable) @deletes.extend(RDF::Enumerable) unless @deletes.kind_of?(RDF::Enumerable) if block_given? case block.arity when 1 then block.call(self) else self.instance_eval(&block) end end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class RDF::Mutable
Instance Attribute Details
#deletes ⇒ RDF::Enumerable (readonly)
RDF statements to delete when applied.
52 53 54 |
# File 'lib/rdf/changeset.rb', line 52 def deletes @deletes end |
#inserts ⇒ RDF::Enumerable (readonly)
RDF statements to insert when applied.
58 59 60 |
# File 'lib/rdf/changeset.rb', line 58 def inserts @inserts end |
#options ⇒ Hash{Symbol => Object} (readonly)
Any additional options for this changeset.
64 65 66 |
# File 'lib/rdf/changeset.rb', line 64 def end |
Class Method Details
.apply(mutable, options = {}) {|changes| ... } ⇒ void
This method returns an undefined value.
Applies a changeset to the given mutable RDF::Enumerable .
44 45 46 |
# File 'lib/rdf/changeset.rb', line 44 def self.apply(mutable, = {}, &block) self.new(&block).apply(mutable, ) end |
Instance Method Details
#apply(mutable, options = {}) ⇒ void
This method returns an undefined value.
Applies this changeset to the given mutable RDF::Enumerable.
This operation executes as a single write transaction.
109 110 111 |
# File 'lib/rdf/changeset.rb', line 109 def apply(mutable, = {}) mutable.apply_changeset(self) end |
#empty? ⇒ Boolean
Returns ‘true` iff inserts and deletes are both empty.
115 116 117 |
# File 'lib/rdf/changeset.rb', line 115 def empty? deletes.empty? && inserts.empty? end |
#inspect ⇒ String
Returns a developer-friendly representation of this changeset.
123 124 125 126 |
# File 'lib/rdf/changeset.rb', line 123 def inspect sprintf("#<%s:%#0x(deletes: %d, inserts: %d)>", self.class.name, self.__id__, self.deletes.count, self.inserts.count) end |
#inspect! ⇒ void
This method returns an undefined value.
Outputs a developer-friendly representation of this changeset to ‘stderr`.
133 134 135 |
# File 'lib/rdf/changeset.rb', line 133 def inspect! $stderr.puts(self.inspect) end |
#readable? ⇒ Boolean
97 98 99 |
# File 'lib/rdf/changeset.rb', line 97 def readable? false end |