Class: Hanami::CLI::Generators::App::Migration Private
- Inherits:
-
Object
- Object
- Hanami::CLI::Generators::App::Migration
- Defined in:
- lib/hanami/cli/generators/app/migration.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.
Instance Method Summary collapse
- #call(key:, base_path:, gateway: nil, **_opts) ⇒ Object private
-
#initialize(fs:, inflector:, out: $stdout) ⇒ Migration
constructor
private
A new instance of Migration.
Constructor Details
#initialize(fs:, inflector:, out: $stdout) ⇒ Migration
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 Migration.
12 13 14 15 16 |
# File 'lib/hanami/cli/generators/app/migration.rb', line 12 def initialize(fs:, inflector:, out: $stdout) @fs = fs @inflector = inflector @out = out end |
Instance Method Details
#call(key:, base_path:, gateway: nil, **_opts) ⇒ 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.
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/hanami/cli/generators/app/migration.rb', line 20 def call(key:, base_path:, gateway: nil, **_opts) name = inflector.underscore(key) ensure_valid_name(name) base_path = nil if base_path == "app" # Migrations are in the root dir, not app/ migrate_dir = gateway ? "#{gateway}_migrate" : "migrate" path = fs.join(*[base_path, "config", "db", migrate_dir, file_name(name)].compact) fs.write(path, FILE_CONTENTS) end |