Class: Mail::FieldList
- Includes:
- Enumerable
- Defined in:
- lib/mail/field_list.rb
Overview
Field List class provides an enhanced array that keeps a list of email fields in order. And allows you to insert new fields without having to worry about the order they will appear in.
Instance Method Summary collapse
Instance Method Details
#<<(new_field) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/mail/field_list.rb', line 11 def <<( new_field ) current_entry = self.rindex(new_field) if current_entry self.insert((current_entry + 1), new_field) else insert_idx = -1 self.each_with_index do |item, idx| case item <=> new_field when -1 next when 0 next when 1 insert_idx = idx break end end insert(insert_idx, new_field) end end |