Class: Turntables::Repository
- Inherits:
-
Object
- Object
- Turntables::Repository
- Includes:
- RepositoryConstants
- Defined in:
- lib/turntables/repository.rb
Overview
and comments about said transaction).
Constant Summary
Constants included from RepositoryConstants
Turntables::RepositoryConstants::MonoDir, Turntables::RepositoryConstants::SeqDir
Instance Attribute Summary collapse
-
#monolithic_dir ⇒ Object
Returns the value of attribute monolithic_dir.
-
#monolithics ⇒ Object
Array<Turntables::Transaction>.
-
#relative_dir ⇒ Object
Returns the value of attribute relative_dir.
-
#sequential_dir ⇒ Object
Returns the value of attribute sequential_dir.
-
#transactions ⇒ Object
Array<Turntables::Transaction>.
Instance Method Summary collapse
-
#initialize ⇒ Repository
constructor
A new instance of Repository.
-
#make! ⇒ Object
Function to call in order to make the database.
-
#malformed? ⇒ Boolean
Check to see if the directory structure is malformed.
- #register(location) ⇒ Object
Constructor Details
#initialize ⇒ Repository
Returns a new instance of Repository.
20 21 22 23 |
# File 'lib/turntables/repository.rb', line 20 def initialize @transactions = Array.new @monolithics = Array.new end |
Instance Attribute Details
#monolithic_dir ⇒ Object
Returns the value of attribute monolithic_dir.
60 61 62 |
# File 'lib/turntables/repository.rb', line 60 def monolithic_dir @monolithic_dir end |
#monolithics ⇒ Object
Array<Turntables::Transaction>
65 66 67 |
# File 'lib/turntables/repository.rb', line 65 def monolithics @monolithics end |
#relative_dir ⇒ Object
Returns the value of attribute relative_dir.
61 62 63 |
# File 'lib/turntables/repository.rb', line 61 def relative_dir @relative_dir end |
#sequential_dir ⇒ Object
Returns the value of attribute sequential_dir.
59 60 61 |
# File 'lib/turntables/repository.rb', line 59 def sequential_dir @sequential_dir end |
#transactions ⇒ Object
Array<Turntables::Transaction>
63 64 65 |
# File 'lib/turntables/repository.rb', line 63 def transactions @transactions end |
Instance Method Details
#make! ⇒ Object
Function to call in order to make the database.
TODO: Here, it should detect in what state the current database is in, and go from there. In other words, whether it can skip sequential database transactions by loading a monolithic one to exclude previous transactions.
42 43 44 45 46 47 48 49 |
# File 'lib/turntables/repository.rb', line 42 def make! select_transactions! @transactions.each do |transaction| vh = VersionHistory.new(transaction.version, transaction.comment) VersionHistory.insert(vh) DbRegistry.instance.execute_batch(transaction.data) end end |
#malformed? ⇒ Boolean
Check to see if the directory structure is malformed.
53 54 55 56 57 |
# File 'lib/turntables/repository.rb', line 53 def malformed? abs_seq = File.(@sequential_dir) abs_mon = File.(@monolithic_dir) !(File.exists?(abs_seq) && File.exists?(abs_mon)) end |
#register(location) ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/turntables/repository.rb', line 27 def register(location) @relative_dir = location @sequential_dir = "#{@relative_dir}/#{SeqDir}/" @monolithic_dir = "#{@relative_dir}/#{MonoDir}/" # Initialize the transactions init_sequential_transactions! init_monolithic_transactions! end |