Skip to content

Commit

Permalink
no need for splat and flatten
Browse files Browse the repository at this point in the history
  • Loading branch information
tenderlove committed Sep 29, 2010
1 parent 93096ae commit bf388f3
Showing 1 changed file with 1 addition and 1 deletion.
Expand Up @@ -360,7 +360,7 @@ def copy_table_indexes(from, to, rename = {}) #:nodoc:
end end


def copy_table_contents(from, to, columns, rename = {}) #:nodoc: def copy_table_contents(from, to, columns, rename = {}) #:nodoc:
column_mappings = Hash[*columns.map {|name| [name, name]}.flatten] column_mappings = Hash[columns.map {|name| [name, name]}]
rename.inject(column_mappings) {|map, a| map[a.last] = a.first; map} rename.inject(column_mappings) {|map, a| map[a.last] = a.first; map}
from_columns = columns(from).collect {|col| col.name} from_columns = columns(from).collect {|col| col.name}
columns = columns.find_all{|col| from_columns.include?(column_mappings[col])} columns = columns.find_all{|col| from_columns.include?(column_mappings[col])}
Expand Down

0 comments on commit bf388f3

Please sign in to comment.