Permalink
Browse files

Invert the conditionals to make easier to read

Also improve some of the code conventions
  • Loading branch information...
1 parent fb522a2 commit baf62e531686ee157746d239037be121f8191275 @rafaelfranca rafaelfranca committed Mar 26, 2014
@@ -186,10 +186,10 @@ def column_exists?(table_name, column_name, type = nil, options = {})
def create_table(table_name, options = {})
td = create_table_definition table_name, options[:temporary], options[:options], options[:as]
- unless options[:id] == false || options[:as]
- pk = options.fetch(:primary_key) {
+ if options[:id] != false && !options[:as]
+ pk = options.fetch(:primary_key) do
Base.get_primary_key table_name.to_s.singularize
- }
+ end
td.primary_key pk, options.fetch(:id, :primary_key), options
end
@@ -201,7 +201,7 @@ def create_table(table_name, options = {})
end
result = execute schema_creation.accept td
- td.indexes.each_pair { |c,o| add_index table_name, c, o } unless supports_indexes_in_create?
+ td.indexes.each_pair { |c, o| add_index(table_name, c, o) } unless supports_indexes_in_create?
result
end

0 comments on commit baf62e5

Please sign in to comment.