private Method

Base.sort_parts(parts, order = [])

There's no documentation for this item.

Source Code

# File action_mailer/base.rb, line 513
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
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.