Class: LB::Persistence
- Inherits:
-
Object
- Object
- LB::Persistence
- Defined in:
- lib/lb/persistence.rb,
lib/lb/persistence/types.rb,
lib/lb/persistence/version.rb,
lib/lb/persistence/settings.rb,
lib/lb/persistence/functions.rb,
lib/lb/persistence/relation/joins.rb,
lib/lb/persistence/model/attributes.rb
Overview
Persistence
Defined Under Namespace
Modules: Functions, Model, Relation, Types Classes: Settings
Constant Summary collapse
- VERSION =
Version
'0.0.8'
Instance Attribute Summary collapse
-
#settings ⇒ Object
readonly
Returns the value of attribute settings.
Instance Method Summary collapse
-
#configuration_for(connection) ⇒ ROM::Configuration
private
Create ROM configuration for given connection or URI.
-
#configure_for(connection) ⇒ ROM::Configuration
private
Configure ROM for given connection or URI.
-
#connect(*args) ⇒ Sequel::Database
private
Connect to database definied by given URI.
-
#container ⇒ ROM::Conatainer
private
Get ROM container.
-
#container_from(config) ⇒ ROM::Container
private
Create ROM container for given config.
-
#initialize(settings) ⇒ Persistence
constructor
A new instance of Persistence.
-
#repository(repository) ⇒ ROM::Repository
private
Get ROM Repository instance for Repository class.
-
#uri ⇒ String
private
Get URI.
Constructor Details
#initialize(settings) ⇒ Persistence
Returns a new instance of Persistence.
21 22 23 |
# File 'lib/lb/persistence.rb', line 21 def initialize(settings) @settings = settings end |
Instance Attribute Details
#settings ⇒ Object (readonly)
Returns the value of attribute settings.
19 20 21 |
# File 'lib/lb/persistence.rb', line 19 def settings @settings end |
Instance Method Details
#configuration_for(connection) ⇒ ROM::Configuration
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Create ROM configuration for given connection or URI
100 101 102 |
# File 'lib/lb/persistence.rb', line 100 def configuration_for(connection) ROM::Configuration.new(:sql, connection) end |
#configure_for(connection) ⇒ ROM::Configuration
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Configure ROM for given connection or URI
66 67 68 |
# File 'lib/lb/persistence.rb', line 66 def configure_for(connection) configure(configuration_for(connection)) end |
#connect(*args) ⇒ Sequel::Database
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Connect to database definied by given URI
54 55 56 |
# File 'lib/lb/persistence.rb', line 54 def connect(*args) Sequel.connect(*args) end |
#container ⇒ ROM::Conatainer
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Get ROM container
31 32 33 |
# File 'lib/lb/persistence.rb', line 31 def container @container ||= rom_setup(uri) end |
#container_from(config) ⇒ ROM::Container
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Create ROM container for given config
88 89 90 |
# File 'lib/lb/persistence.rb', line 88 def container_from(config) ROM.container(config) end |
#repository(repository) ⇒ ROM::Repository
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Get ROM Repository instance for Repository class
41 42 43 |
# File 'lib/lb/persistence.rb', line 41 def repository(repository) repository.new(container) end |
#uri ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Get URI
76 77 78 |
# File 'lib/lb/persistence.rb', line 76 def uri @uri ||= settings.database_uri end |