Sha256: 3d14b48cdadb7192981c0f19618f5a0010cd02747eddb048c5de1991ceb8da02

Contents?: true

Size: 822 Bytes

Versions: 20

Compression:

Stored size: 822 Bytes

Contents

require 'scorpion/nest'

module Scorpion
  module Rails

    # Adds a scorpion nest to support injection into rails mailers.
    module Mailer


      def self.included( base )
        # Setup dependency injection
        base.send :include, Scorpion::Object
        base.send :include, Scorpion::Rails::Nest
        base.send :around_filter, :with_scorpion

        super
      end

      private

        def prepare_scorpion( scorpion )
          scorpion.prepare do |hunter|
            hunter.hunt_for ActionMailer::Base do
              self
            end
          end
        end

        attr_reader :scorpion
        def assign_scorpion( scorpion )
          @scorpion = scorpion
        end

        def free_scorpion
          @scorpion.try( :destroy )
          @scorpion = nil
        end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
scorpion-ioc-0.5.23 lib/scorpion/rails/mailer.rb
scorpion-ioc-0.5.22 lib/scorpion/rails/mailer.rb
scorpion-ioc-0.5.21 lib/scorpion/rails/mailer.rb
scorpion-ioc-0.5.20 lib/scorpion/rails/mailer.rb
scorpion-ioc-0.5.19 lib/scorpion/rails/mailer.rb
scorpion-ioc-0.5.18 lib/scorpion/rails/mailer.rb
scorpion-ioc-0.5.17 lib/scorpion/rails/mailer.rb
scorpion-ioc-0.5.16 lib/scorpion/rails/mailer.rb
scorpion-ioc-0.5.15 lib/scorpion/rails/mailer.rb
scorpion-ioc-0.5.14 lib/scorpion/rails/mailer.rb
scorpion-ioc-0.5.13 lib/scorpion/rails/mailer.rb
scorpion-ioc-0.5.12 lib/scorpion/rails/mailer.rb
scorpion-ioc-0.5.11 lib/scorpion/rails/mailer.rb
scorpion-ioc-0.5.10 lib/scorpion/rails/mailer.rb
scorpion-ioc-0.5.9 lib/scorpion/rails/mailer.rb
scorpion-ioc-0.5.8 lib/scorpion/rails/mailer.rb
scorpion-ioc-0.5.7 lib/scorpion/rails/mailer.rb
scorpion-ioc-0.5.6 lib/scorpion/rails/mailer.rb
scorpion-ioc-0.5.5 lib/scorpion/rails/mailer.rb
scorpion-ioc-0.5.4 lib/scorpion/rails/mailer.rb