Sha256: 24ce5dcc7d9cba35f6a1bc214294d5c4912642c0461f7c5ed5f1ffcca5154edd

Contents?: true

Size: 1010 Bytes

Versions: 31

Compression:

Stored size: 1010 Bytes

Contents

# frozen_string_literal: true

require 'rails/generators/active_record'

module Emailbutler
  module Generators
    class ActiveRecordGenerator < ::Rails::Generators::Base
      include ::Rails::Generators::Migration
      desc 'Generates migration for emailbutler 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_emailbutler_tables.rb', options
      end

      def migration_version
        self.class.migration_version
      end
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
emailbutler-0.8.8 lib/generators/emailbutler/active_record_generator.rb
emailbutler-0.8.7 lib/generators/emailbutler/active_record_generator.rb
emailbutler-0.8.6 lib/generators/emailbutler/active_record_generator.rb
emailbutler-0.8.5 lib/generators/emailbutler/active_record_generator.rb
emailbutler-0.8.4 lib/generators/emailbutler/active_record_generator.rb
emailbutler-0.8.3 lib/generators/emailbutler/active_record_generator.rb
emailbutler-0.8.2 lib/generators/emailbutler/active_record_generator.rb
emailbutler-0.8.1 lib/generators/emailbutler/active_record_generator.rb
emailbutler-0.7.6 lib/generators/emailbutler/active_record_generator.rb
emailbutler-0.7.5 lib/generators/emailbutler/active_record_generator.rb
emailbutler-0.7.4 lib/generators/emailbutler/active_record_generator.rb
emailbutler-0.7.3 lib/generators/emailbutler/active_record_generator.rb
emailbutler-0.7.2 lib/generators/emailbutler/active_record_generator.rb
emailbutler-0.7.1 lib/generators/emailbutler/active_record_generator.rb
emailbutler-0.7.0 lib/generators/emailbutler/active_record_generator.rb
emailbutler-0.6.1 lib/generators/emailbutler/active_record_generator.rb
emailbutler-0.6.0 lib/generators/emailbutler/active_record_generator.rb
emailbutler-0.5.9 lib/generators/emailbutler/active_record_generator.rb
emailbutler-0.5.8 lib/generators/emailbutler/active_record_generator.rb
emailbutler-0.5.7 lib/generators/emailbutler/active_record_generator.rb