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.
# File lib/mail/field_list.rb, line 11 11: def <<( new_field ) 12: current_entry = self.rindex(new_field.name) 13: if current_entry 14: self.insert((current_entry + 1), new_field) 15: else 16: insert_idx = 1 17: self.each_with_index do |item, idx| 18: case item <=> new_field 19: when 1 20: next 21: when 0 22: next 23: when 1 24: insert_idx = idx 25: break 26: end 27: end 28: insert(insert_idx, new_field) 29: end 30: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.