lib/redlander/model.rb in redlander-0.3.5 vs lib/redlander/model.rb in redlander-0.3.6
- old
+ new
@@ -1,5 +1,10 @@
+require 'redlander/storage'
+require 'redlander/parser'
+require 'redlander/serializer'
+require 'redlander/model_proxy'
+
module Redlander
class Model
include Redlander::ParsingInstanceMethods
include Redlander::SerializingInstanceMethods
@@ -26,20 +31,20 @@
# Wrap changes to the given model in a transaction.
# If an exception is raised in the block, the transaction is rolled back.
# (Does not work for all storages, in which case the changes are instanteous).
def transaction
if block_given?
- Redland.librdf_model_transaction_start(@rdf_model).zero? || RedlandError.new("Failed to initialize a transaction")
+ Redland.librdf_model_transaction_start(@rdf_model).zero? || raise(RedlandError, "Failed to initialize a transaction")
yield
- Redland.librdf_model_transaction_commit(@rdf_model).zero? || RedlandError.new("Failed to commit the transaction")
+ Redland.librdf_model_transaction_commit(@rdf_model).zero? || raise(RedlandError, "Failed to commit the transaction")
end
rescue
rollback
raise
end
# Rollback the transaction
def rollback
- Redland.librdf_model_transaction_rollback(@rdf_model).zero? || RedlandError.new("Failed to rollback the latest transaction")
+ Redland.librdf_model_transaction_rollback(@rdf_model).zero? || raise(RedlandError, "Failed to rollback the latest transaction")
end
end
end