lib/rom/sql/migration/writer.rb in rom-sql-3.1.0 vs lib/rom/sql/migration/writer.rb in rom-sql-3.2.0
- old
+ new
@@ -1,5 +1,7 @@
+# frozen_string_literal: true
+
require 'rom/sql/migration/recorder'
module ROM
module SQL
module Migration
@@ -30,31 +32,37 @@
def write(operations, buffer, indent)
operations.each do |operation|
op, args, nested = operation
buffer << indent << op.to_s << ' '
- write_arguments(buffer, *args)
+ write_arguments(buffer, args)
if !nested.empty?
buffer << ' do'
write(nested, buffer, indent + ' ')
buffer << indent << 'end'
end
end
end
- def write_arguments(buffer, *args, **kwargs)
+ def write_arguments(buffer, args)
+ if args.last.is_a?(::Hash)
+ args, options = args[0...-1], args.last
+ else
+ options = EMPTY_HASH
+ end
+
buffer << args.map(&:inspect).join(', ')
- kwargs.each do |key, value|
+ options.each do |key, value|
buffer << ', ' << key.to_s << ': ' << value.inspect
end
end
def migration_name(op)
create_or_alter, args = op
table_name = args[0]
- "#{ create_or_alter.to_s.sub('_table', '') }_#{ table_name }"
+ "#{create_or_alter.to_s.sub('_table', '')}_#{table_name}"
end
end
end
end
end