aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/arel/attributes.rb
blob: 35d586c948c2dd7211c78c97fd252c4503167880 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# frozen_string_literal: true

require "arel/attributes/attribute"

module Arel # :nodoc: all
  module Attributes
    ###
    # Factory method to wrap a raw database +column+ to an Arel Attribute.
    def self.for(column)
      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
        Undefined
      end
    end
  end
end