Class: Kuby::Plugins::RailsApp::Database
- Inherits:
-
Object
- Object
- Kuby::Plugins::RailsApp::Database
- Defined in:
- lib/kuby/plugins/rails_app/database.rb
Constant Summary collapse
Instance Attribute Summary collapse
-
#rails_app ⇒ Object
readonly
Returns the value of attribute rails_app.
Class Method Summary collapse
Instance Method Summary collapse
- #adapter_name ⇒ Object (also: #plugin_name)
-
#initialize(rails_app) ⇒ Database
constructor
A new instance of Database.
- #plugin ⇒ Object
Constructor Details
#initialize(rails_app) ⇒ Database
Returns a new instance of Database.
29 30 31 |
# File 'lib/kuby/plugins/rails_app/database.rb', line 29 def initialize(rails_app) @rails_app = rails_app end |
Instance Attribute Details
#rails_app ⇒ Object (readonly)
Returns the value of attribute rails_app.
27 28 29 |
# File 'lib/kuby/plugins/rails_app/database.rb', line 27 def rails_app @rails_app end |
Class Method Details
.get(rails_app) ⇒ Object
14 15 16 17 18 |
# File 'lib/kuby/plugins/rails_app/database.rb', line 14 def self.get(rails_app) if rails_app.manage_database? new(rails_app) end end |
.get_adapter(adapter_name) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/kuby/plugins/rails_app/database.rb', line 20 def self.get_adapter(adapter_name) ADAPTER_MAP.fetch(adapter_name) do raise UnsupportedDatabaseError, "Kuby does not support the '#{adapter_name}' "\ 'database adapter' end end |
Instance Method Details
#adapter_name ⇒ Object Also known as: plugin_name
39 40 41 |
# File 'lib/kuby/plugins/rails_app/database.rb', line 39 def adapter_name @adapter_name ||= db_config['adapter'].to_sym end |
#plugin ⇒ Object
33 34 35 36 37 |
# File 'lib/kuby/plugins/rails_app/database.rb', line 33 def plugin @plugin ||= self.class .get_adapter(adapter_name) .new(rails_app.environment, db_configs) end |