Skip to content
Browse files

Merge branch 'table_monkey' into more_monkeypatches

  • Loading branch information...
2 parents bf0be2b + 177abfa commit fac4ea21f66bba4138a09bed8310813846e00a67 @kbrock committed Sep 24, 2012
Showing with 24 additions and 25 deletions.
  1. +24 −25 lib/postgres_ext/active_record/connection_adapters/postgres_adapter.rb
View
49 lib/postgres_ext/active_record/connection_adapters/postgres_adapter.rb
@@ -137,31 +137,6 @@ def column_with_extended_types(name, type=nil, options = {})
alias_method_chain :column, :extended_types
end
- class Table < ActiveRecord::ConnectionAdapters::Table
- EXTENDED_TYPES.keys.map(&:to_s).each do |column_type|
- class_eval <<-EOV, __FILE__, __LINE__ + 1
- def #{column_type}(*args) # def string(*args)
- options = args.extract_options! # options = args.extract_options!
- column_names = args # column_names = args
- type = :'#{column_type}' # type = :string
- column_names.each do |name| # column_names.each do |name|
- column = ColumnDefinition.new(@base, name.to_s, type) # column = ColumnDefinition.new(@base, name, type)
- if options[:limit] # if options[:limit]
- column.limit = options[:limit] # column.limit = options[:limit]
- elsif native[type].is_a?(Hash) # elsif native[type].is_a?(Hash)
- column.limit = native[type][:limit] # column.limit = native[type][:limit]
- end # end
- column.precision = options[:precision] # column.precision = options[:precision]
- column.scale = options[:scale] # column.scale = options[:scale]
- column.default = options[:default] # column.default = options[:default]
- column.null = options[:null] # column.null = options[:null]
- @base.add_column(@table_name, name, column.sql_type, options) # @base.add_column(@table_name, name, column.sql_type, options)
- end # end
- end # end
- EOV
- end
- end
-
NATIVE_DATABASE_TYPES.merge!(EXTENDED_TYPES)
alias :add_column_options_without_extended_types :add_column_options!
@@ -225,5 +200,29 @@ def array_to_string(value, column)
"{#{value.map{|val| type_cast(val, column, true)}.join(',')}}"
end
end
+ class Table
+ PostgreSQLAdapter::EXTENDED_TYPES.keys.map(&:to_s).each do |column_type|
+ class_eval <<-EOV, __FILE__, __LINE__ + 1
+ def #{column_type}(*args) # def string(*args)
+ options = args.extract_options! # options = args.extract_options!
+ column_names = args # column_names = args
+ type = :'#{column_type}' # type = :string
+ column_names.each do |name| # column_names.each do |name|
+ column = ColumnDefinition.new(@base, name.to_s, type) # column = ColumnDefinition.new(@base, name, type)
+ if options[:limit] # if options[:limit]
+ column.limit = options[:limit] # column.limit = options[:limit]
+ elsif native[type].is_a?(Hash) # elsif native[type].is_a?(Hash)
+ column.limit = native[type][:limit] # column.limit = native[type][:limit]
+ end # end
+ column.precision = options[:precision] # column.precision = options[:precision]
+ column.scale = options[:scale] # column.scale = options[:scale]
+ column.default = options[:default] # column.default = options[:default]
+ column.null = options[:null] # column.null = options[:null]
+ @base.add_column(@table_name, name, column.sql_type, options) # @base.add_column(@table_name, name, column.sql_type, options)
+ end # end
+ end # end
+ EOV
+ end
+ end
end
end

0 comments on commit fac4ea2

Please sign in to comment.
Something went wrong with that request. Please try again.