Sha256: c673d2b9d0567b948e7ffe1de4b9e626327fc5836c0638f03f06312f6826bcad

Contents?: true

Size: 877 Bytes

Versions: 6

Compression:

Stored size: 877 Bytes

Contents

require 'rails/generators/active_record'
require 'rails/generators/migration'

# Blindly copied from acts-as-taggable-on
module DeathAndTaxes
  class MigrationGenerator < Rails::Generators::Base
    include Rails::Generators::Migration
    
    desc "Generates migrations for taxations"
    
    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
      ActiveRecord::Generators::Base.next_migration_number path
    end
    
    def create_migration_file
      if self.class.orm_has_migration?
        migration_template 'migration.rb', 'db/migrate/death_and_taxes_migration'
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
death_and_taxes-0.0.5 lib/generators/death_and_taxes/migration/migration_generator.rb
death_and_taxes-0.0.4 lib/generators/death_and_taxes/migration/migration_generator.rb
death_and_taxes-0.0.3 lib/generators/death_and_taxes/migration/migration_generator.rb
death_and_taxes-0.0.2 lib/generators/death_and_taxes/migration/migration_generator.rb
death_and_taxes-0.0.1 lib/generators/death_and_taxes/migration/migration_generator.rb
death_and_taxes-0.0.0 lib/generators/death_and_taxes/migration/migration_generator.rb