attributes.rb 610 B

1234567891011121314151617181920
  1. require 'arel/attributes/attribute'
  2. module Arel
  3. module Attributes
  4. ###
  5. # Factory method to wrap a raw database +column+ to an Arel Attribute.
  6. def self.for column
  7. case column.type
  8. when :string, :text, :binary then String
  9. when :integer then Integer
  10. when :float then Float
  11. when :decimal then Decimal
  12. when :date, :datetime, :timestamp, :time then Time
  13. when :boolean then Boolean
  14. else
  15. Undefined
  16. end
  17. end
  18. end
  19. end