0
@@ -476,12 +476,12 @@ module ActiveRecord
0
%w( string text integer float decimal datetime timestamp time date binary boolean ).each do |column_type|
0
- def #{column_type}(*args)
0
- options = args.extract_options!
0
- column_names.each { |name| column(name, '#{column_type}', options) }
0
+ def #{column_type}(*args) # def string(*args)
0
+ options = args.extract_options! # options = args.extract_options!
0
+ column_names = args # column_names = args
0
+ column_names.each { |name| column(name, '#{column_type}', options) } # column_names.each { |name| column(name, 'string', options) }
0
@@ -676,24 +676,24 @@ module ActiveRecord
0
# t.string(:goat, :sheep)
0
%w( string text integer float decimal datetime timestamp time date binary boolean ).each do |column_type|
0
- def #{column_type}(*args)
0
- options = args.extract_options!
0
- column_names.each do |name|
0
- column = ColumnDefinition.new(@base, name, '#{column_type}')
0
- column.limit = options[:limit]
0
- elsif native['#{column_type}'.to_sym].is_a?(Hash)
0
- column.limit = native['#{column_type}'.to_sym][:limit]
0
- column.precision = options[:precision]
0
- column.scale = options[:scale]
0
- column.default = options[:default]
0
- column.null = options[:null]
0
- @base.add_column(@table_name, name, column.sql_type, options)
0
+ def #{column_type}(*args) # def string(*args)
0
+ options = args.extract_options! # options = args.extract_options!
0
+ column_names = args # column_names = args
0
+ column_names.each do |name| # column_names.each do |name|
0
+ column = ColumnDefinition.new(@base, name, '#{column_type}') # column = ColumnDefinition.new(@base, name, 'string')
0
+ if options[:limit] # if options[:limit]
0
+ column.limit = options[:limit] # column.limit = options[:limit]
0
+ elsif native['#{column_type}'.to_sym].is_a?(Hash) # elsif native['string'.to_sym].is_a?(Hash)
0
+ column.limit = native['#{column_type}'.to_sym][:limit] # column.limit = native['string'.to_sym][:limit]
0
+ column.precision = options[:precision] # column.precision = options[:precision]
0
+ column.scale = options[:scale] # column.scale = options[:scale]
0
+ column.default = options[:default] # column.default = options[:default]
0
+ column.null = options[:null] # column.null = options[:null]
0
+ @base.add_column(@table_name, name, column.sql_type, options) # @base.add_column(@table_name, name, column.sql_type, options)
Beautiful. I like this.
nice
Feels like this should be a language feature, or at least a post processing tool.
There are a couple of places where there are comments above the code, rather than beside. The end result can appear to be code which has been disabled, rather than an explanation. In particular, I think that the annotation in activerecord/lib/active_record/base.rb needs to be annotated.
Yes, we discussed the trade-offs in the IRC.
Those examples are there exceptionally because the lines would be really too wide. Check the section “Dinamically Generated Method” of the API conventions (http://wiki.github.com/lifo/docrails/rails-api-documentation-conventions)