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
- DEFAULT_ENGINE =
'filesystem'.freeze
Instance Attribute Summary collapse
- #engine ⇒ Object readonly
- #name ⇒ Object readonly
Instance Method Summary collapse
- #filesystem? ⇒ Boolean
-
#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.
22 23 24 25 26 27 |
# File 'lib/lotus/generators/database_config.rb', line 22 def initialize(engine, name) @engine = engine @name = name SUPPORTED_ENGINES.key?(engine.to_s) or fail "\"#{ engine }\" is not a valid database type" end |
Instance Attribute Details
#engine ⇒ Object (readonly)
20 21 22 |
# File 'lib/lotus/generators/database_config.rb', line 20 def engine @engine end |
#name ⇒ Object (readonly)
20 21 22 |
# File 'lib/lotus/generators/database_config.rb', line 20 def name @name end |
Instance Method Details
#filesystem? ⇒ Boolean
45 46 47 |
# File 'lib/lotus/generators/database_config.rb', line 45 def filesystem? type == :file_system end |
#sql? ⇒ Boolean
41 42 43 |
# File 'lib/lotus/generators/database_config.rb', line 41 def sql? type == :sql end |
#to_hash ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/lotus/generators/database_config.rb', line 29 def to_hash { gem: gem, uri: uri, type: type } end |
#type ⇒ Object
37 38 39 |
# File 'lib/lotus/generators/database_config.rb', line 37 def type SUPPORTED_ENGINES[engine][:type] end |