Class: ROM::Rails::Configuration
- Inherits:
-
Object
- Object
- ROM::Rails::Configuration
- Defined in:
- lib/rom/rails/configuration.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#env ⇒ Object
readonly
Returns the value of attribute env.
-
#setup ⇒ Object
readonly
Returns the value of attribute setup.
Class Method Summary collapse
Instance Method Summary collapse
- #finalize! ⇒ Object
-
#initialize(config) ⇒ Configuration
constructor
A new instance of Configuration.
- #load! ⇒ Object
- #setup! ⇒ Object
Constructor Details
#initialize(config) ⇒ Configuration
Returns a new instance of Configuration.
13 14 15 |
# File 'lib/rom/rails/configuration.rb', line 13 def initialize(config) @config = config end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
4 5 6 |
# File 'lib/rom/rails/configuration.rb', line 4 def config @config end |
#env ⇒ Object (readonly)
Returns the value of attribute env.
4 5 6 |
# File 'lib/rom/rails/configuration.rb', line 4 def env @env end |
#setup ⇒ Object (readonly)
Returns the value of attribute setup.
4 5 6 |
# File 'lib/rom/rails/configuration.rb', line 4 def setup @setup end |
Class Method Details
.build(app) ⇒ Object
6 7 8 9 10 11 |
# File 'lib/rom/rails/configuration.rb', line 6 def self.build(app) config = app.config.database_configuration[::Rails.env]. symbolize_keys.update(root: app.config.root) new(ROM::Config.build(config)) end |
Instance Method Details
#finalize! ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/rom/rails/configuration.rb', line 25 def finalize! # rescuing fixes the chicken-egg problem where we have a relation # defined but the table doesn't exist yet @env = ROM.finalize.env rescue Registry::ElementNotFoundError => e warn "Skipping ROM setup => #{e.}" end |
#load! ⇒ Object
21 22 23 |
# File 'lib/rom/rails/configuration.rb', line 21 def load! Railtie.load_all end |
#setup! ⇒ Object
17 18 19 |
# File 'lib/rom/rails/configuration.rb', line 17 def setup! @setup = ROM.setup(@config.symbolize_keys) end |