Sha256: 237d667fb759de431588df32289e8448f7a2ca2bceeb7ec67aa8cc0b6d2eace2

Contents?: true

Size: 964 Bytes

Versions: 1

Compression:

Stored size: 964 Bytes

Contents

module Bushido
  module Generators
    class MailRoutesGenerator < Rails::Generators::Base
  
      def create_mail_routes_file
        # Create the lib/bushido directory if it doesnt exist
        Dir.mkdir("#{Rails.root}/lib/bushido") if not Dir.exists? "#{Rails.root}/lib/bushido"
        
        lib "bushido/mail_routes.rb" do
          <<-EOF
::Bushido::Mailroute.map do |m|

  m.route("simple") do
    m.subject("hello")
  end

end
          EOF
        end

        lib("bushido/hooks/email_hooks.rb") do
          <<-EOF
class BushidoEmailHooks < Bushido::EventObserver

  def mail_simple
    puts "YAY!"
    puts params.inspect
  end

end
          EOF
        end
        
        initializer "bushido_hooks.rb" do
          <<-EOF
Dir["\#{Dir.pwd}/lib/bushido/**/*.rb"].each { |file| require file }
          EOF
        end
        
        initializer("bushido_mail_routes.rb", "require './lib/bushido/mail_routes.rb'")

      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bushido-0.0.36 lib/generators/bushido/mail_routes_generator.rb