Displaying 1 result from an estimated 1 matches for "convert_to".
2006 Mar 03
0
unused composed_of bits
...l and a number of conversions and bang conversions
attr_reader :temp, :units
def initialize( temperature, units = "F" )
   unless valid_units?(units)
     units = "F"
   end
   @temp = temperature = ((10 * temperature).to_f.round)/10.0
   @units = units.upcase
end
def to_c
   convert_to("C")
end
... etc.
So in my app model:
class Profile < ActiveRecord::Base
   composed_of :temperature, :class_name => Temperature,
               :mapping => [ :temp, :temp ]
   def before_save
     self.temperature.to_f!
   end
The table corresponding to Profile has a column...