Sha256: bc05851a2b277f322246d43472564d0faa0f76df4b33aa14b690e064a3a8feac

Contents?: true

Size: 865 Bytes

Versions: 2

Compression:

Stored size: 865 Bytes

Contents

require 'rails/generators/migration'

module TeleNotify
  class MigrationGenerator < Rails::Generators::Base
    include Rails::Generators::Migration

    desc "Generates migration for votable (votes table)"

    def self.orm
      Rails::Generators.options[:rails][:orm]
    end

    def self.source_root
      File.join(File.dirname(__FILE__), 'templates', (orm.to_s unless orm.class.eql?(String)) )
    end

    def self.orm_has_migration?
      [:active_record].include? orm
    end

    def self.next_migration_number(path)
      Time.now.utc.strftime("%Y%m%d%H%M%S")
    end

    def create_migration_file
      if self.class.orm_has_migration?
        migration_template 'migration.rb', 'db/migrate/tele_notify_migration.rb'
      end
    end

    def copy_initializer
      copy_file 'tele_notify.rb', 'config/initializers/tele_notify.rb'
    end
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
TelegemBot-0.1.1 lib/generators/tele_notify/migration/migration_generator.rb
tele_notify-0.1.1 lib/generators/tele_notify/migration/migration_generator.rb