Sha256: 35fd4e22b55703893bc25d296d66f67dbe5fa16d812278296078af54b39b5e48

Contents?: true

Size: 823 Bytes

Versions: 3

Compression:

Stored size: 823 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_action, :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

3 entries across 3 versions & 1 rubygems

Version Path
scorpion-ioc-0.6.2 lib/scorpion/rails/mailer.rb
scorpion-ioc-0.6.1 lib/scorpion/rails/mailer.rb
scorpion-ioc-0.6.0 lib/scorpion/rails/mailer.rb