From c0899bca10af443d3aba00d75c554b96d4bccdab Mon Sep 17 00:00:00 2001 From: Marcel Molina Date: Thu, 6 Oct 2005 23:19:55 +0000 Subject: 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 --- .../connection_adapters/abstract/schema_definitions.rb | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'activerecord/lib/active_record/connection_adapters/abstract') 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. -- cgit v1.2.3