Module: Rubydora::Transactions

Extended by:
ActiveSupport::Concern
Defined in:
lib/rubydora/transactions.rb

Overview

Extremely basic (and naive) ‘transaction’ support for Rubydora. This isn’t really intended to be used in a production-like situation – more for rolling back (small) changes during testing.

Class Attribute Summary collapse

Instance Method Summary collapse

Class Attribute Details

.use_transactionsObject

Returns the value of attribute use_transactions.



9
10
11
# File 'lib/rubydora/transactions.rb', line 9

def use_transactions
  @use_transactions
end

Instance Method Details

#append_to_transactions_log(*args) ⇒ Object

Unshift a transaction entry onto the transaction logs. We want these entries in reverse-chronological order for ease of undoing..



75
76
77
78
# File 'lib/rubydora/transactions.rb', line 75

def append_to_transactions_log *args
  return unless Rubydora::Transactions.use_transactions
  transactions_log.unshift(args)
end

#transaction(&block) ⇒ Object

Start a transaction



67
68
69
70
# File 'lib/rubydora/transactions.rb', line 67

def transaction &block
  Transaction.new self, &block
  self.transactions_log.clear
end

#transactions_logObject

The repository transaction log.



81
82
83
# File 'lib/rubydora/transactions.rb', line 81

def transactions_log
  @log ||= []
end