aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters
diff options
context:
space:
mode:
authorMarcel Molina <marcel@vernix.org>2005-10-06 23:19:55 +0000
committerMarcel Molina <marcel@vernix.org>2005-10-06 23:19:55 +0000
commitc0899bca10af443d3aba00d75c554b96d4bccdab (patch)
tree584bbc01fb922528839d62022ac8a38725479b36 /activerecord/lib/active_record/connection_adapters
parente8b427cdefd9ec851e2853d4bf21dd8fd676096d (diff)
downloadrails-c0899bca10af443d3aba00d75c554b96d4bccdab.tar.gz
rails-c0899bca10af443d3aba00d75c554b96d4bccdab.tar.bz2
rails-c0899bca10af443d3aba00d75c554b96d4bccdab.zip
Add convenience predicate methods on Column class. In partial fullfilment of #1236.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2482 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters')
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb14
1 files changed, 13 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
index 36f282d22a..1a633dcc00 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
@@ -5,6 +5,7 @@ module ActiveRecord
# An abstract definition of a column in a table.
class Column
attr_reader :name, :default, :type, :limit, :null
+ attr_accessor :primary
# Instantiates a new column in the table.
#
@@ -16,7 +17,18 @@ module ActiveRecord
@name, @type, @null = name, simplified_type(sql_type), null
# have to do this one separately because type_cast depends on #type
@default = type_cast(default)
- @limit = extract_limit(sql_type) unless sql_type.nil?
+ @limit = extract_limit(sql_type) unless sql_type.nil?
+ @primary = nil
+ @text = [:string, :text].include? @type
+ @number = [:float, :integer].include? @type
+ end
+
+ def text?
+ @text
+ end
+
+ def number?
+ @number
end
# Returns the Ruby class that corresponds to the abstract data type.