instance method sort_parts

Ruby on Rails 2.3.18

Since v2.2.3 Last seen in v2.3.18 Private

Available in: v2.2.3 v2.3.18

Signature

sort_parts(parts, order = [])

No documentation comment.

Parameters

parts req
order opt = []
Source
# File actionmailer/lib/action_mailer/base.rb, line 638
      def sort_parts(parts, order = [])
        order = order.collect { |s| s.downcase }

        parts = parts.sort do |a, b|
          a_ct = a.content_type.downcase
          b_ct = b.content_type.downcase

          a_in = order.include? a_ct
          b_in = order.include? b_ct

          s = case
          when a_in && b_in
            order.index(a_ct) <=> order.index(b_ct)
          when a_in
            -1
          when b_in
            1
          else
            a_ct <=> b_ct
          end

          # reverse the ordering because parts that come last are displayed
          # first in mail clients
          (s * -1)
        end

        parts
      end

Defined in actionmailer/lib/action_mailer/base.rb line 638 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActionMailer::Base

Type at least 2 characters to search.

↑↓ navigate · open · esc close