def add_formats(type, *add_formats)
formats = send("#{type}_formats")
options = add_formats.last.is_a?(Hash) ? add_formats.pop : {}
before = options[:before]
raise FormatNotFound, "Format for :before option #{before.inspect} was not found." if before && !formats.include?(before)
add_formats.each do |format|
raise DuplicateFormat, "Format #{format.inspect} is already included in #{type.inspect} formats" if formats.include?(format)
index = before ? formats.index(before) : -1
formats.insert(index, format)
end
compile_formats
end