Class: Pigeon::Generators::Hanami::MigrationGenerator
- Inherits:
-
Object
- Object
- Pigeon::Generators::Hanami::MigrationGenerator
- Defined in:
- lib/pigeon/generators/hanami/migration_generator.rb
Overview
Generator for creating the outbox message table migration for Hanami applications
Instance Attribute Summary collapse
-
#app_name ⇒ Object
readonly
Returns the value of attribute app_name.
Instance Method Summary collapse
-
#generate ⇒ String
Generate the migration file.
-
#initialize(app_name = nil) ⇒ MigrationGenerator
constructor
A new instance of MigrationGenerator.
Constructor Details
#initialize(app_name = nil) ⇒ MigrationGenerator
Returns a new instance of MigrationGenerator.
12 13 14 |
# File 'lib/pigeon/generators/hanami/migration_generator.rb', line 12 def initialize(app_name = nil) @app_name = app_name || detect_app_name end |
Instance Attribute Details
#app_name ⇒ Object (readonly)
Returns the value of attribute app_name.
10 11 12 |
# File 'lib/pigeon/generators/hanami/migration_generator.rb', line 10 def app_name @app_name end |
Instance Method Details
#generate ⇒ String
Generate the migration file
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/pigeon/generators/hanami/migration_generator.rb', line 18 def generate = Time.now.utc.strftime("%Y%m%d%H%M%S") filename = "db/migrations/#{}_create_outbox_messages.rb" # Create the migrations directory if it doesn't exist FileUtils.mkdir_p("db/migrations") # Write the migration file File.write(filename, migration_content) filename end |