Sha256: c91bf3d62b6c12d87676e3d62180450dbb4223e1f8cbc6c9102436bbc6bc3161

Contents?: true

Size: 968 Bytes

Versions: 51

Compression:

Stored size: 968 Bytes

Contents

require 'rails/generators/active_record'

module Flipper
  module Generators
    class ActiveRecordGenerator < ::Rails::Generators::Base
      include ::Rails::Generators::Migration
      desc 'Generates migration for flipper tables'

      source_paths << File.join(File.dirname(__FILE__), 'templates')

      def self.next_migration_number(dirname)
        ::ActiveRecord::Generators::Base.next_migration_number(dirname)
      end

      def self.migration_version
        "[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]" if requires_migration_number?
      end

      def self.requires_migration_number?
        Rails::VERSION::MAJOR.to_i >= 5
      end

      def create_migration_file
        options = {
          migration_version: migration_version,
        }
        migration_template 'migration.erb', 'db/migrate/create_flipper_tables.rb', options
      end

      def migration_version
        self.class.migration_version
      end
    end
  end
end

Version data entries

51 entries across 51 versions & 1 rubygems

Version Path
flipper-active_record-1.3.2 lib/generators/flipper/active_record_generator.rb
flipper-active_record-1.3.1 lib/generators/flipper/active_record_generator.rb
flipper-active_record-1.3.0 lib/generators/flipper/active_record_generator.rb
flipper-active_record-1.3.0.pre lib/generators/flipper/active_record_generator.rb
flipper-active_record-1.2.2 lib/generators/flipper/active_record_generator.rb
flipper-active_record-1.2.1 lib/generators/flipper/active_record_generator.rb
flipper-active_record-1.2.0 lib/generators/flipper/active_record_generator.rb
flipper-active_record-1.1.2 lib/generators/flipper/active_record_generator.rb
flipper-active_record-1.1.1 lib/generators/flipper/active_record_generator.rb
flipper-active_record-1.1.0 lib/generators/flipper/active_record_generator.rb
flipper-active_record-1.0.0 lib/generators/flipper/active_record_generator.rb
flipper-active_record-1.0.0.pre lib/generators/flipper/active_record_generator.rb
flipper-active_record-0.28.3 lib/generators/flipper/active_record_generator.rb
flipper-active_record-0.28.2 lib/generators/flipper/active_record_generator.rb
flipper-active_record-0.28.1 lib/generators/flipper/active_record_generator.rb
flipper-active_record-0.28.0 lib/generators/flipper/active_record_generator.rb
flipper-active_record-0.27.1 lib/generators/flipper/active_record_generator.rb
flipper-active_record-0.27.0 lib/generators/flipper/active_record_generator.rb
flipper-active_record-0.26.2 lib/generators/flipper/active_record_generator.rb
flipper-active_record-0.26.1 lib/generators/flipper/active_record_generator.rb