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
Overview
Persistence
Defined Under Namespace
Modules: Functions, Relation, Types Classes: Settings
Constant Summary collapse
- VERSION =
Version
'0.3.0'
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.
20 21 22 |
# File 'lib/lb/persistence.rb', line 20 def initialize(settings) @settings = settings end |
Instance Attribute Details
#settings ⇒ Object (readonly)
Returns the value of attribute settings.
18 19 20 |
# File 'lib/lb/persistence.rb', line 18 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
99 100 101 |
# File 'lib/lb/persistence.rb', line 99 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
65 66 67 |
# File 'lib/lb/persistence.rb', line 65 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
53 54 55 |
# File 'lib/lb/persistence.rb', line 53 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
30 31 32 |
# File 'lib/lb/persistence.rb', line 30 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
87 88 89 |
# File 'lib/lb/persistence.rb', line 87 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
40 41 42 |
# File 'lib/lb/persistence.rb', line 40 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
75 76 77 |
# File 'lib/lb/persistence.rb', line 75 def uri @uri ||= settings.database_uri end |