Class: Lims::Core::Persistence::Store
- Defined in:
- lib/lims-core/persistence/store.rb
Overview
A store represents a persistent datastore, where object can be saved and restored. A connection to a database, for example.
Direct Known Subclasses
Constant Summary collapse
- DIRTY_ATTRIBUTE_STRATEGY_DEEP_COPY =
1- DIRTY_ATTRIBUTE_STRATEGY_SHA1 =
2- DIRTY_ATTRIBUTE_STRATEGY_MD5 =
3- DIRTY_ATTRIBUTE_STRATEGY_QUICK_HASH =
4
Instance Attribute Summary collapse
-
#dirty_attribute_strategy ⇒ Object
The dirty-attribute strategy decides how object modification is detected to avoid saved unmodified object.
Class Method Summary collapse
-
.base_module ⇒ Module
Retrieves the effective module of a class Useful to call “sibling” classes.
- .const_missing(name) ⇒ Object
Instance Method Summary collapse
- #base_module ⇒ Object
-
#create_session(*params) ⇒ Object
Create a session If a session is given a parameter return in instead of creating a new one.
-
#transaction ⇒ Object
Execute given block within a transaction If it make sense.
-
#with_session(*params) {|session| ... } ⇒ Object
Create a session and pass it to the block.
Instance Attribute Details
#dirty_attribute_strategy ⇒ Object
The dirty-attribute strategy decides how object modification is detected to avoid saved unmodified object.
19 20 21 |
# File 'lib/lims-core/persistence/store.rb', line 19 def dirty_attribute_strategy @dirty_attribute_strategy end |
Class Method Details
.base_module ⇒ Module
Retrieves the effective module of a class Useful to call “sibling” classes.
37 38 39 40 41 42 |
# File 'lib/lims-core/persistence/store.rb', line 37 def self.base_module @base_module ||= begin base_name = name.sub(/::\w+$/, '') constant(base_name) end end |
.const_missing(name) ⇒ Object
12 13 14 |
# File 'lib/lims-core/persistence/store.rb', line 12 def self.const_missing(name) super(name) end |
Instance Method Details
#base_module ⇒ Object
43 44 45 |
# File 'lib/lims-core/persistence/store.rb', line 43 def base_module self.class.base_module end |
#create_session(*params) ⇒ Object
Create a session If a session is given a parameter return in instead of creating a new one.
60 61 62 63 |
# File 'lib/lims-core/persistence/store.rb', line 60 def create_session(*params) return params.first if(params.size >= 1 && params.first.is_a?(Session)) base_module::Session.new(self, *params) end |
#transaction ⇒ Object
Execute given block within a transaction If it make sense.
67 68 69 |
# File 'lib/lims-core/persistence/store.rb', line 67 def transaction yield end |
#with_session(*params) {|session| ... } ⇒ Object
Create a session and pass it to the block. This is the only way to get a session.
52 53 54 |
# File 'lib/lims-core/persistence/store.rb', line 52 def with_session(*params, &block) create_session(*params).with_session(&block) end |