Class: Hanami::CLI::Commands::New::DatabaseConfig Private
- Inherits:
-
Object
- Object
- Hanami::CLI::Commands::New::DatabaseConfig
- Defined in:
- lib/hanami/cli/commands/new.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Constant Summary collapse
- SUPPORTED_ENGINES =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
{ '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' } }.freeze
- DEFAULT_ENGINE =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
'sqlite'.freeze
Instance Attribute Summary collapse
- #engine ⇒ Object readonly private
- #name ⇒ Object readonly private
Instance Method Summary collapse
-
#initialize(engine, name) ⇒ DatabaseConfig
constructor
private
A new instance of DatabaseConfig.
- #sql? ⇒ Boolean private
- #sqlite? ⇒ Boolean private
- #to_hash ⇒ Object private
- #type ⇒ Object private
Constructor Details
#initialize(engine, name) ⇒ DatabaseConfig
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of DatabaseConfig.
40 41 42 43 44 45 46 47 48 |
# File 'lib/hanami/cli/commands/new.rb', line 40 def initialize(engine, name) @engine = engine @name = name unless SUPPORTED_ENGINES.key?(engine.to_s) # rubocop:disable Style/GuardClause warn %(`#{engine}' is not a valid database engine) exit(1) end end |
Instance Attribute Details
#engine ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
32 33 34 |
# File 'lib/hanami/cli/commands/new.rb', line 32 def engine @engine end |
#name ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
36 37 38 |
# File 'lib/hanami/cli/commands/new.rb', line 36 def name @name end |
Instance Method Details
#sql? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
68 69 70 |
# File 'lib/hanami/cli/commands/new.rb', line 68 def sql? type == :sql end |
#sqlite? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
74 75 76 |
# File 'lib/hanami/cli/commands/new.rb', line 74 def sqlite? %w[sqlite sqlite3].include?(engine) end |
#to_hash ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
52 53 54 55 56 57 58 |
# File 'lib/hanami/cli/commands/new.rb', line 52 def to_hash { gem: gem, uri: uri, type: type } end |
#type ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
62 63 64 |
# File 'lib/hanami/cli/commands/new.rb', line 62 def type SUPPORTED_ENGINES[engine][:type] end |