Sha256: 25ba2442aa693484e1ca4fa960f863a1f5c045422dc53b578f67bd67170dea22

Contents?: true

Size: 772 Bytes

Versions: 13

Compression:

Stored size: 772 Bytes

Contents

require 'rails/generators/migration'

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

    desc "Generates migration for Custom Attribute models"

    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/custom_attributes_migration'
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
custom-attributes-0.2.27 lib/generators/custom_attributes/migration/migration_generator.rb
custom-attributes-0.2.26 lib/generators/custom_attributes/migration/migration_generator.rb
custom-attributes-0.2.25 lib/generators/custom_attributes/migration/migration_generator.rb
custom-attributes-0.2.24 lib/generators/custom_attributes/migration/migration_generator.rb
custom-attributes-0.2.23 lib/generators/custom_attributes/migration/migration_generator.rb
custom-attributes-0.2.22 lib/generators/custom_attributes/migration/migration_generator.rb
custom-attributes-0.2.18 lib/generators/custom_attributes/migration/migration_generator.rb
custom-attributes-0.2.17 lib/generators/custom_attributes/migration/migration_generator.rb
custom-attributes-0.2.16 lib/generators/custom_attributes/migration/migration_generator.rb
custom-attributes-0.2.15 lib/generators/custom_attributes/migration/migration_generator.rb
custom-attributes-0.2.12 lib/generators/custom_attributes/migration/migration_generator.rb
custom-attributes-0.2.5 lib/generators/custom_attributes/migration/migration_generator.rb
custom-attributes-0.2.4 lib/generators/acts_as_taggable_on/migration/migration_generator.rb