datamapper/dm-serializer — Issue #25: dm-serializer redefines the global CSV constant on Ruby 1.8
Author: rsutphin
Created: 2011-12-13 15:16:11+00:00
State: open

`dm-serializer/to_csv.rb` redefines the global `CSV` constant to be an alias to `FasterCSV` when running under Ruby 1.8. While I understand the desire to keep the remainder of the code the same under 1.8 and 1.9, this causes two problems:

* If the built-in CSV library has already been required when dm-serializer is loaded, you get a constant redefinition warning.
* If the built-in CSV library is required after dm-serializer (e.g., by another library) you get a `superclass mismatch for class Row` error.

An alternative: define a method on `DataMapper::Serializer` that returns the appropriate module to use (CSV or FasterCSV) depending on the ruby version.