Module: Arel::Attributes

Defined in:
lib/arel/attributes.rb,
lib/arel/attributes/attribute.rb

Defined Under Namespace

Classes: Attribute, Boolean, Decimal, Float, Integer, String, Time, Undefined

Class Method Summary collapse

Class Method Details

.for(column) ⇒ Object

Factory method to wrap a raw database column to an Arel Attribute.



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/arel/attributes.rb', line 9

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