Class: BetterAuth::Hanami::Generators::MigrationGenerator
- Inherits:
-
Object
- Object
- BetterAuth::Hanami::Generators::MigrationGenerator
- Defined in:
- lib/better_auth/hanami/generators/migration_generator.rb
Instance Method Summary collapse
-
#initialize(destination_root: Dir.pwd, configuration: nil, force: false) ⇒ MigrationGenerator
constructor
A new instance of MigrationGenerator.
- #run(force: nil) ⇒ Object
Constructor Details
#initialize(destination_root: Dir.pwd, configuration: nil, force: false) ⇒ MigrationGenerator
Returns a new instance of MigrationGenerator.
10 11 12 13 14 |
# File 'lib/better_auth/hanami/generators/migration_generator.rb', line 10 def initialize(destination_root: Dir.pwd, configuration: nil, force: false) @destination_root = destination_root @configuration = configuration @force = force end |
Instance Method Details
#run(force: nil) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/better_auth/hanami/generators/migration_generator.rb', line 16 def run(force: nil) force = @force if force.nil? return existing_migration_path if existing_migration_path && !force path = existing_migration_path || migration_path FileUtils.mkdir_p(File.dirname(path)) File.write(path, BetterAuth::Hanami::Migration.render(generator_config)) path end |