aboutsummaryrefslogblamecommitdiffstats
path: root/lib/arel/attributes.rb
blob: a7fb00293b130ba3c728f7f1dc1df4b1afad3a28 (plain) (tree)



















                                                                                          
require 'arel/attributes/attribute'

module Arel
  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
        raise NotImplementedError, "Column type `#{column.type}` is not currently handled"
      end
    end
  end
end