Class: Lims::Core::Persistence::Sequel::Store

Inherits:
Lims::Core::Persistence::Store show all
Defined in:
lib/lims-core/persistence/sequel/store.rb

Overview

An Sequel::Store, ie an wrapper around a database using the sequel gem

Constant Summary

Constants inherited from Lims::Core::Persistence::Store

Lims::Core::Persistence::Store::DIRTY_ATTRIBUTE_STRATEGY_DEEP_COPY, Lims::Core::Persistence::Store::DIRTY_ATTRIBUTE_STRATEGY_MD5, Lims::Core::Persistence::Store::DIRTY_ATTRIBUTE_STRATEGY_QUICK_HASH, Lims::Core::Persistence::Store::DIRTY_ATTRIBUTE_STRATEGY_SHA1

Instance Attribute Summary collapse

Attributes inherited from Lims::Core::Persistence::Store

#dirty_attribute_strategy

Instance Method Summary collapse

Methods inherited from Lims::Core::Persistence::Store

#base_module, base_module, const_missing, #create_session, #with_session

Constructor Details

#initialize(database, *args) ⇒ Store

Create a store with a Sequel::Database We don’t wrap for now the creation of the database

Parameters:

  • type (Sequel::Database)

    underlying database

Raises:

  • (RuntimeError)


19
20
21
22
23
24
# File 'lib/lims-core/persistence/sequel/store.rb', line 19

def initialize(database, *args)
  raise RuntimeError unless database.is_a?(::Sequel::Database)
  @database = database
  super(*args)
  @dirty_attribute_strategy = DIRTY_ATTRIBUTE_STRATEGY_SHA1
end

Instance Attribute Details

#databaseObject (readonly)

Returns the value of attribute database.



13
14
15
# File 'lib/lims-core/persistence/sequel/store.rb', line 13

def database
  @database
end

Instance Method Details

#transactionObject

Execute given block within a transaction and create a session object needed to update revisionned table.



29
30
31
32
33
# File 'lib/lims-core/persistence/sequel/store.rb', line 29

def transaction
  database.transaction do
    super
  end
end