diff --git a/lib/rdf/repository.rb b/lib/rdf/repository.rb index e9efc817..2d1f4fb3 100644 --- a/lib/rdf/repository.rb +++ b/lib/rdf/repository.rb @@ -124,16 +124,18 @@ def initialize(uri: nil, title: nil, **options, &block) ## # Returns `true` if this respository supports the given `feature`. # - # Supported features include those from {RDF::Enumerable#supports?} along with the following: - # * `:transactions` supports atomic transactions - # * `:snapshots` supports creation of immutable snapshots of current contents via #snapshot. + # Supported features include those from {RDF::Enumerable#supports?} along + # with the following: + # * `:atomic_write` supports atomic write in transaction scopes + # * `:snapshots` supports creation of immutable snapshots of current + # contents via #snapshot. # @see RDF::Enumerable#supports? def supports?(feature) case feature.to_sym when :graph_name then @options[:with_graph_name] when :inference then false # forward-chaining inference when :validity then @options.fetch(:with_validity, true) - when :transactions then false + when :atomic_write then false when :snapshots then false else false end @@ -272,7 +274,7 @@ def supports?(feature) when :graph_name then @options[:with_graph_name] when :inference then false # forward-chaining inference when :validity then @options.fetch(:with_validity, true) - when :transactions then true + when :atomic_write then true when :snapshots then true else false end diff --git a/lib/rdf/transaction.rb b/lib/rdf/transaction.rb index f0021a0c..a4dc8a8c 100644 --- a/lib/rdf/transaction.rb +++ b/lib/rdf/transaction.rb @@ -6,7 +6,7 @@ module RDF # # Repository implementations may provide support for transactional updates # by providing an atomic implementation of {Mutable#apply_changeset} and - # responding to `#supports?(:transactions)` with `true`. + # responding to `#supports?(:atomic_write)` with `true`. # # We carefully distinguish between read-only and read/write transactions, # in order to enable repository implementations to take out the @@ -18,7 +18,7 @@ module RDF # transaction's scope. In case repository implementations should be unable # to provide full ACID guarantees for transactions, that must be clearly # indicated in their documentation. If update atomicity is not provided, - # `#supports?(:transactions)` must respond `false`. + # `#supports?(:atomic_write)` must respond `false`. # # @example Executing a read-only transaction # repository = RDF::Repository.new @@ -145,7 +145,11 @@ def initialize(repository, mutable: false, **options, &block) repository.supports?(:snapshots) ? repository.snapshot : repository @options = options.dup @mutable = mutable - + + raise TransactionError, + 'Tried to open a mutable transaction on an immutable repository' if + @mutable && !@repository.mutable? + @changes = RDF::Changeset.new if block_given? diff --git a/spec/model_graph_spec.rb b/spec/model_graph_spec.rb index 70739ec6..5eadaa92 100644 --- a/spec/model_graph_spec.rb +++ b/spec/model_graph_spec.rb @@ -171,6 +171,10 @@ it_behaves_like 'an RDF::Queryable' end + context 'transactions' do + it { require 'pry'; binding.pry } + end + context "Examples" do let(:graph) {described_class.new}