Sha256: 60417c8a7ce7ede0bcd00e239c2b50d0bec71299e8b95dcdd307a77918153d83

Contents?: true

Size: 781 Bytes

Versions: 13

Compression:

Stored size: 781 Bytes

Contents

# Helper logic for the enum generator
module EnumGeneratorHelpers
  # Helper methods to figure out the migration number.
  module MigrationNumber
    # Returns the next upcoming migration number.  Sadly, Rails has no API for
    # this, so we're reduced to copying from ActiveRecord::Generators::Migration
    # @return [Fixnum]
    def next_migration_number(dirname)
      # Lifted directly from ActiveRecord::Generators::Migration
      # Unfortunately, no API is provided by Rails at this time.
      next_migration_number = current_migration_number(dirname) + 1
      if ActiveRecord::Base.timestamped_migrations
        [Time.now.utc.strftime("%Y%m%d%H%M%S"), "%.14d" % next_migration_number].max
      else
        "%.3d" % next_migration_number
      end
    end

  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
power_enum-2.10.1 lib/generators/enum/enum_generator_helpers/migration_number.rb
power_enum-2.10.0 lib/generators/enum/enum_generator_helpers/migration_number.rb
power_enum-2.9.1 lib/generators/enum/enum_generator_helpers/migration_number.rb
power_enum-2.9.0 lib/generators/enum/enum_generator_helpers/migration_number.rb
power_enum-2.8.0 lib/generators/enum/enum_generator_helpers/migration_number.rb
power_enum-2.7.1 lib/generators/enum/enum_generator_helpers/migration_number.rb
power_enum-2.7.0 lib/generators/enum/enum_generator_helpers/migration_number.rb
power_enum-2.6.0 lib/generators/enum/enum_generator_helpers/migration_number.rb
power_enum-2.5.0 lib/generators/enum/enum_generator_helpers/migration_number.rb
power_enum-2.4.0 lib/generators/enum/enum_generator_helpers/migration_number.rb
power_enum-2.3.0 lib/generators/enum/enum_generator_helpers/migration_number.rb
power_enum-2.2.0 lib/generators/enum/enum_generator_helpers/migration_number.rb
power_enum-1.4.0 lib/generators/enum/enum_generator_helpers/migration_number.rb