Sha256: 6cc48d524938829d9a0dc5bec519b1a2eda94f1ae395dea0e66bd8b444c0ad80

Contents?: true

Size: 1.1 KB

Versions: 17

Compression:

Stored size: 1.1 KB

Contents

module Hobo
  class UserMailerGenerator < Rails::Generators::NamedBase
    source_root File.expand_path('../templates', __FILE__)

    # overrides the default
    argument :name, :type => :string, :default => 'user', :optional => true

    include Generators::Hobo::InviteOnly
    include Generators::Hobo::ActivationEmail

    def self.banner
      "rails generate hobo:user_mailer [NAME=user] [options]"
    end

    check_class_collision :suffix => 'Mailer'

    def generate_mailer
      template 'mailer.rb.erb', File.join('app/mailers', "#{file_path}_mailer.rb")
    end

    def generate_mails
      mailer_dir = File.join("app/views", class_path[0..-2], "#{file_name.singularize}_mailer")
      template 'forgot_password.erb', File.join(mailer_dir, "forgot_password.erb")
      template( 'invite.erb', File.join(mailer_dir, "invite.erb")) if invite_only?
      template( 'activation.erb', File.join(mailer_dir, "activation.erb")) if options[:activation_email]
    end

    hook_for :test_framework, :as => :mailer do | instance, mailer |
      instance.invoke mailer, ["#{instance.name}_mailer"]
    end

  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
hobo-1.3.0.pre27 lib/generators/hobo/user_mailer/user_mailer_generator.rb
hobo-1.3.0.pre26 lib/generators/hobo/user_mailer/user_mailer_generator.rb
hobo-1.3.0.pre25 lib/generators/hobo/user_mailer/user_mailer_generator.rb
hobo-1.3.0.pre24 lib/generators/hobo/user_mailer/user_mailer_generator.rb
hobo-1.3.0.pre23 lib/generators/hobo/user_mailer/user_mailer_generator.rb
hobo-1.3.0.pre22 lib/generators/hobo/user_mailer/user_mailer_generator.rb
hobo-1.3.0.pre21 lib/generators/hobo/user_mailer/user_mailer_generator.rb
hobo-1.3.0.pre20 lib/generators/hobo/user_mailer/user_mailer_generator.rb
hobo-1.3.0.pre19 lib/generators/hobo/user_mailer/user_mailer_generator.rb
hobo-1.3.0.pre18 lib/generators/hobo/user_mailer/user_mailer_generator.rb
hobo-1.3.0.pre16 lib/generators/hobo/user_mailer/user_mailer_generator.rb
hobo-1.3.0.pre15 lib/generators/hobo/user_mailer/user_mailer_generator.rb
hobo-1.3.0.pre14 lib/generators/hobo/user_mailer/user_mailer_generator.rb
hobo-1.3.0.pre13 lib/generators/hobo/user_mailer/user_mailer_generator.rb
hobo-1.3.0.pre12 lib/generators/hobo/user_mailer/user_mailer_generator.rb
hobo-1.3.0.pre11 lib/generators/hobo/user_mailer/user_mailer_generator.rb
hobo-1.3.0.pre10 lib/generators/hobo/user_mailer/user_mailer_generator.rb