2017-02-13 13:58:58 -05:00
|
|
|
# frozen_string_literal: true
|
2018-02-24 01:45:50 -05:00
|
|
|
|
|
|
|
require "arel/attributes/attribute"
|
2010-08-12 17:55:31 -04:00
|
|
|
|
2018-02-24 02:41:47 -05:00
|
|
|
module Arel # :nodoc: all
|
2010-08-12 17:55:31 -04:00
|
|
|
module Attributes
|
|
|
|
###
|
|
|
|
# Factory method to wrap a raw database +column+ to an Arel Attribute.
|
2018-02-24 01:45:50 -05:00
|
|
|
def self.for(column)
|
2010-08-12 17:55:31 -04:00
|
|
|
case column.type
|
|
|
|
when :string, :text, :binary then String
|
|
|
|
when :integer then Integer
|
|
|
|
when :float then Float
|
|
|
|
when :decimal then Decimal
|
|
|
|
when :date, :datetime, :timestamp, :time then Time
|
|
|
|
when :boolean then Boolean
|
|
|
|
else
|
2010-11-16 11:09:26 -05:00
|
|
|
Undefined
|
2010-08-12 17:55:31 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|