Class: Migflow::Services::MigrationSummaryBuilder
- Inherits:
-
Object
- Object
- Migflow::Services::MigrationSummaryBuilder
- Defined in:
- lib/migflow/services/migration_summary_builder.rb
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(raw_content:, version:) ⇒ MigrationSummaryBuilder
constructor
A new instance of MigrationSummaryBuilder.
Constructor Details
#initialize(raw_content:, version:) ⇒ MigrationSummaryBuilder
Returns a new instance of MigrationSummaryBuilder.
12 13 14 15 |
# File 'lib/migflow/services/migration_summary_builder.rb', line 12 def initialize(raw_content:, version:) @raw_content = raw_content.to_s @version = version end |
Class Method Details
.call(raw_content:, version:) ⇒ Object
8 9 10 |
# File 'lib/migflow/services/migration_summary_builder.rb', line 8 def self.call(raw_content:, version:) new(raw_content: raw_content, version: version).call end |
Instance Method Details
#call ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/migflow/services/migration_summary_builder.rb', line 17 def call scanner = MigrationDslScanner.new(@raw_content) created_tables = scanner.create_table_blocks.map(&:first) return "Created table #{created_tables.join(", ")}" if created_tables.any? dropped_tables = scanner.drop_tables return "Dropped table #{dropped_tables.join(", ")}" if dropped_tables.any? added_details = added_column_details(scanner) + added_reference_details(scanner) return "Added #{added_details.join(", ")}" if added_details.any? "Migration #{@version}" end |