Sha256: 1aed9f5e189c98790e7e74a43b408cb86e97958ab5d4057eca0c7c66997b80f9

Contents?: true

Size: 876 Bytes

Versions: 5

Compression:

Stored size: 876 Bytes

Contents

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

class ArMailerAwsGenerator < Rails::Generators::NamedBase
  include Rails::Generators::Migration

  source_root File.expand_path('../templates', __FILE__)

  def create_ar_mailer_files
    self.class.check_class_collision class_name
    template('ar_mailer_aws.rb', 'config/initializers/ar_mailer_aws.rb')
    template('model.rb', File.join('app/models', class_path, "#{file_name}.rb"))
    migration_template 'migration.rb', "db/migrate/create_#{file_path.gsub(/\//, '_').pluralize}.rb"
  end
  
  def self.next_migration_number(dirname)
    if ActiveRecord::Base.timestamped_migrations
      Time.now.utc.strftime('%Y%m%d%H%M%S')
    else
     '%.3d' % (current_migration_number(dirname) + 1)
   end
  end
  
  def self.banner
    'Usage: rails ar_mailer_aws EmailModelName (default: BatchEmail)'
  end  
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ar_mailer_aws-0.1.0 lib/generators/ar_mailer_aws/ar_mailer_aws_generator.rb
ar_mailer_aws-0.0.4 lib/generators/ar_mailer_aws/ar_mailer_aws_generator.rb
ar_mailer_aws-0.0.3 lib/generators/ar_mailer_aws/ar_mailer_aws_generator.rb
ar_mailer_aws-0.0.2 lib/generators/ar_mailer_aws/ar_mailer_aws_generator.rb
ar_mailer_aws-0.0.1 lib/generators/ar_mailer_aws/ar_mailer_aws_generator.rb