Codegeneration in Model slow

hello list,

i've got the following code snippet in my model to generate extra
helper functions.

    def transform_to_boolean {|c| c.sql_type == "varchar(1)"}.each do


        define_method "#{}".to_sym do
          v = self.attributes[]
          v = (v ? v.upcase : "F")
          if (v == "W" || v == "T")

this functionality takes over 1,2 sec for one instance of the model.
It has to iterate over 260 columns.

Do you have an idea how to speed up this piece of functionality?

best regards,


this is the call of evil
v = self.attributes[]
i change it to
v = self.read_attribute(

its much faster.

why do you need to call this on each instance ?