Skip to content

Commit

Permalink
Revert "Revert "Merge pull request #9206 from ranjaykrishna/use_defin…
Browse files Browse the repository at this point in the history
…e_method""

This reverts commit 8aa4603.

Reverting the revert because I reverted the wrong thing! Fail.
  • Loading branch information
jonleighton committed Feb 15, 2013
1 parent 8aa4603 commit 2f99779
Showing 1 changed file with 13 additions and 18 deletions.
Expand Up @@ -252,15 +252,12 @@ def column(name, type, options = {})
self self
end end


%w( string text integer float decimal datetime timestamp time date binary boolean ).each do |column_type| [:string, :text, :integer, :float, :decimal, :datetime, :timestamp, :time, :date, :binary, :boolean].each do |column_type|
class_eval <<-EOV, __FILE__, __LINE__ + 1 define_method column_type do |*args|
def #{column_type}(*args) # def string(*args) options = args.extract_options!
options = args.extract_options! # options = args.extract_options! column_names = args
column_names = args # column_names = args column_names.each { |name| column(name, column_type, options) }
type = :'#{column_type}' # type = :string end
column_names.each { |name| column(name, type, options) } # column_names.each { |name| column(name, type, options) }
end # end
EOV
end end


# Adds index options to the indexes hash, keyed by column name # Adds index options to the indexes hash, keyed by column name
Expand Down Expand Up @@ -486,15 +483,13 @@ def remove_references(*args)
# #
# t.string(:goat) # t.string(:goat)
# t.string(:goat, :sheep) # t.string(:goat, :sheep)
%w( string text integer float decimal datetime timestamp time date binary boolean ).each do |column_type| [:string, :text, :integer, :float, :decimal, :datetime, :timestamp, :time, :date, :binary, :boolean].each do |column_type|
class_eval <<-EOV, __FILE__, __LINE__ + 1 define_method column_type do |*args|
def #{column_type}(*args) # def string(*args) options = args.extract_options!
options = args.extract_options! # options = args.extract_options! args.each do |name|
args.each do |name| # column_names.each do |name| @base.add_column(@table_name, name, column_type, options)
@base.add_column(@table_name, name, :#{column_type}, options) # @base.add_column(@table_name, name, :string, options) end
end # end end
end # end
EOV
end end


private private
Expand Down

0 comments on commit 2f99779

Please sign in to comment.