def [](index_value)
      if index_value.is_a?(Integer)
        self.fetch(index_value)
      else
        self.select { |a| a.filename == index_value }.first
      end
    end
def [](index_value)
      if index_value.is_a?(Integer)
        self.fetch(index_value)
      else
        self.select { |a| a.filename == index_value }.first
      end
    end
Returns the attachment by filename or at index.

 mail.attachments['test.png'] = File.read('test.png')
 mail.attachments['test.jpg'] = File.read('test.jpg')

 mail.attachments['test.png'].filename #=> 'test.png'
 mail.attachments[1].filename          #=> 'test.jpg'