Class: Lotus::Generators::DatabaseConfig
- Inherits:
-
Object
- Object
- Lotus::Generators::DatabaseConfig
- Defined in:
- lib/lotus/generators/database_config.rb
Overview
Constant Summary collapse
- SUPPORTED_ENGINES =
{ 'mysql' => { type: :sql, mri: 'mysql2', jruby: 'jdbc-mysql' }, 'mysql2' => { type: :sql, mri: 'mysql2', jruby: 'jdbc-mysql' }, 'postgresql' => { type: :sql, mri: 'pg', jruby: 'jdbc-postgres' }, 'postgres' => { type: :sql, mri: 'pg', jruby: 'jdbc-postgres' }, 'sqlite' => { type: :sql, mri: 'sqlite3', jruby: 'jdbc-sqlite3' }, 'sqlite3' => { type: :sql, mri: 'sqlite3', jruby: 'jdbc-sqlite3' }, 'filesystem' => { type: :file_system, mri: nil, jruby: nil }, 'memory' => { type: :memory, mri: nil, jruby: nil } }.freeze
Instance Attribute Summary collapse
- #engine ⇒ Object readonly
- #name ⇒ Object readonly
Instance Method Summary collapse
-
#initialize(engine, name) ⇒ DatabaseConfig
constructor
A new instance of DatabaseConfig.
- #sql? ⇒ Boolean
- #to_hash ⇒ Object
- #type ⇒ Object
Constructor Details
#initialize(engine, name) ⇒ DatabaseConfig
Returns a new instance of DatabaseConfig.
17 18 19 20 21 22 |
# File 'lib/lotus/generators/database_config.rb', line 17 def initialize(engine, name) @engine = engine @name = name SUPPORTED_ENGINES.key?(engine) or fail "\"#{ engine }\" is not a valid database type" end |
Instance Attribute Details
#engine ⇒ Object (readonly)
15 16 17 |
# File 'lib/lotus/generators/database_config.rb', line 15 def engine @engine end |
#name ⇒ Object (readonly)
15 16 17 |
# File 'lib/lotus/generators/database_config.rb', line 15 def name @name end |
Instance Method Details
#sql? ⇒ Boolean
36 37 38 |
# File 'lib/lotus/generators/database_config.rb', line 36 def sql? type == :sql end |
#to_hash ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/lotus/generators/database_config.rb', line 24 def to_hash { gem: gem, uri: uri, type: type } end |
#type ⇒ Object
32 33 34 |
# File 'lib/lotus/generators/database_config.rb', line 32 def type SUPPORTED_ENGINES[engine][:type] end |