Sha256: 497e23eadfc44d6158852629b6221bf9007370e0d02434b8cfe00ff45efcd88c

Contents?: true

Size: 1.49 KB

Versions: 48

Compression:

Stored size: 1.49 KB

Contents

require 'action_mailer'

module Incline::Extensions

  ##
  # Adds the default_hostname, default_sender, and default_recipient methods to the ApplicationMailer::Base class.
  module ActionMailerBase

    ##
    # Adds the extra class methods to the ApplicationMailer::Base class.
    module ClassMethods
      ##
      # Gets the default hostname for messages.
      def default_hostname
        @default_hostname ||= Incline::email_config[:default_hostname]
      end

      ##
      # Gets the default sender for messages.
      def default_sender
        @default_sender ||= Incline::email_config[:sender]
      end

      ##
      # Gets the default recipient for messages.
      def default_recipient
        @default_recipient ||= Incline::email_config[:default_recipient]
      end
    end

    ##
    # Sets the default from and to address according to the configuration.
    def self.included(base)
      base.extend ClassMethods

      class << self

        private

        if method_defined?(:inherited)
          alias_method :incline_original_inherited, :inherited
        else
          def incline_original_inherited(subclass)
            # Do nothing.
          end
        end

        def inherited(subclass)
          incline_original_inherited subclass

          default(
              {
                  from: default_sender,
                  to: default_recipient
              }
          )
        end
      end

    end

  end

end

ActionMailer::Base.include Incline::Extensions::ActionMailerBase

Version data entries

48 entries across 48 versions & 1 rubygems

Version Path
incline-0.3.14 lib/incline/extensions/action_mailer_base.rb
incline-0.3.13 lib/incline/extensions/action_mailer_base.rb
incline-0.3.12 lib/incline/extensions/action_mailer_base.rb
incline-0.3.11 lib/incline/extensions/action_mailer_base.rb
incline-0.3.10 lib/incline/extensions/action_mailer_base.rb
incline-0.3.9 lib/incline/extensions/action_mailer_base.rb
incline-0.3.8 lib/incline/extensions/action_mailer_base.rb
incline-0.3.7 lib/incline/extensions/action_mailer_base.rb
incline-0.3.6 lib/incline/extensions/action_mailer_base.rb
incline-0.3.5 lib/incline/extensions/action_mailer_base.rb
incline-0.3.4 lib/incline/extensions/action_mailer_base.rb
incline-0.3.3 lib/incline/extensions/action_mailer_base.rb
incline-0.3.2 lib/incline/extensions/action_mailer_base.rb
incline-0.3.1 lib/incline/extensions/action_mailer_base.rb
incline-0.3.0 lib/incline/extensions/action_mailer_base.rb
incline-0.2.36 lib/incline/extensions/action_mailer_base.rb
incline-0.2.35 lib/incline/extensions/action_mailer_base.rb
incline-0.2.34 lib/incline/extensions/action_mailer_base.rb
incline-0.2.28 lib/incline/extensions/action_mailer_base.rb
incline-0.2.27 lib/incline/extensions/action_mailer_base.rb