aboutsummaryrefslogtreecommitdiffstats
path: root/lib/arel/attributes.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/arel/attributes.rb')
-rw-r--r--lib/arel/attributes.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/arel/attributes.rb b/lib/arel/attributes.rb
new file mode 100644
index 0000000000..a7fb00293b
--- /dev/null
+++ b/lib/arel/attributes.rb
@@ -0,0 +1,20 @@
+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