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.2.26 lib/incline/extensions/action_mailer_base.rb
incline-0.2.25 lib/incline/extensions/action_mailer_base.rb
incline-0.2.24 lib/incline/extensions/action_mailer_base.rb
incline-0.2.23 lib/incline/extensions/action_mailer_base.rb
incline-0.2.22 lib/incline/extensions/action_mailer_base.rb
incline-0.2.21 lib/incline/extensions/action_mailer_base.rb
incline-0.2.20 lib/incline/extensions/action_mailer_base.rb
incline-0.2.19 lib/incline/extensions/action_mailer_base.rb
incline-0.2.18 lib/incline/extensions/action_mailer_base.rb
incline-0.2.17 lib/incline/extensions/action_mailer_base.rb
incline-0.2.16 lib/incline/extensions/action_mailer_base.rb
incline-0.2.15 lib/incline/extensions/action_mailer_base.rb
incline-0.2.14 lib/incline/extensions/action_mailer_base.rb
incline-0.2.13 lib/incline/extensions/action_mailer_base.rb
incline-0.2.12 lib/incline/extensions/action_mailer_base.rb
incline-0.2.11 lib/incline/extensions/action_mailer_base.rb
incline-0.2.10 lib/incline/extensions/action_mailer_base.rb
incline-0.2.9 lib/incline/extensions/action_mailer_base.rb
incline-0.2.8 lib/incline/extensions/action_mailer_base.rb
incline-0.2.7 lib/incline/extensions/action_mailer_base.rb