Sha256: c44a0f98b1e710ba8a787fd056cc416f026df664520d2cdee0b999eb8d793bc0

Contents?: true

Size: 823 Bytes

Versions: 9

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

9 entries across 9 versions & 1 rubygems

Version Path
scorpion-ioc-1.0.10 lib/scorpion/rails/mailer.rb
scorpion-ioc-1.0.8 lib/scorpion/rails/mailer.rb
scorpion-ioc-1.0.7 lib/scorpion/rails/mailer.rb
scorpion-ioc-1.0.6 lib/scorpion/rails/mailer.rb
scorpion-ioc-1.0.4 lib/scorpion/rails/mailer.rb
scorpion-ioc-1.0.3 lib/scorpion/rails/mailer.rb
scorpion-ioc-1.0.2 lib/scorpion/rails/mailer.rb
scorpion-ioc-1.0.1 lib/scorpion/rails/mailer.rb
scorpion-ioc-1.0.0 lib/scorpion/rails/mailer.rb