infused/dbf — pull request #43 by norbert (2012-04-14 17:10:20+00:00)
Title: Improve handling of record attributes

This branch removes the `Attributes` class and changes the handling of attributes in the `Record` class.

Right now there is a bug in the way `define_accessors` works. Because `define_method` is called on `Record` the accessor methods are defined for all instances. Using `method_missing` and `respond_to?` avoids this problem. This is related to #37 and #38.

Duplicating the values in the `Attributes` class seemed unnecessary. This version of `Record#attributes` returns a plain hash that has only the original column names as keys, **which is different from the current return value**. To allow "indifferent" access to attributes `Record#[]` now works the same as the ActiveRecord equivalent.

Although I haven't benchmarked the difference extensively, both fixing the duplication and removing `define_accessors` from `initialize` seem to cause a significant speed increase. This new implementation could still use some work but only one test had to be changed. Finally, I cleaned up some unrelated code in the process.