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.
31 32 33 |
# File 'lib/kuby/plugins/rails_app/database.rb', line 31 def initialize(rails_app) @rails_app = rails_app end |
Instance Attribute Details
#rails_app ⇒ Object (readonly)
Returns the value of attribute rails_app.
29 30 31 |
# File 'lib/kuby/plugins/rails_app/database.rb', line 29 def rails_app @rails_app end |
Class Method Details
.get(rails_app) ⇒ Object
16 17 18 19 20 |
# File 'lib/kuby/plugins/rails_app/database.rb', line 16 def self.get(rails_app) if rails_app.manage_database? new(rails_app) end end |
.get_adapter(adapter_name) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/kuby/plugins/rails_app/database.rb', line 22 def self.get_adapter(adapter_name) ADAPTER_MAP.fetch(adapter_name) do raise UnsupportedDatabaseError, "Kuby does not support the '#{adapter}' "\ 'database adapter' end end |
Instance Method Details
#adapter_name ⇒ Object Also known as: plugin_name
41 42 43 |
# File 'lib/kuby/plugins/rails_app/database.rb', line 41 def adapter_name @adapter_name ||= db_config['adapter'].to_sym end |
#plugin ⇒ Object
35 36 37 38 39 |
# File 'lib/kuby/plugins/rails_app/database.rb', line 35 def plugin @plugin ||= self.class .get_adapter(adapter_name) .new(rails_app.environment, db_configs) end |