lib/dbf/schema.rb in dbf-4.3.0 vs lib/dbf/schema.rb in dbf-4.3.1

- old
+ new

@@ -33,32 +33,32 @@ # end # # @param format [Symbol] format Valid options are :activerecord and :json # @param table_only [Boolean] # @return [String] - def schema(format = :activerecord, table_only = false) + def schema(format = :activerecord, table_only: false) schema_method_name = schema_name(format) - send(schema_method_name, table_only) + send(schema_method_name, table_only:) rescue NameError raise ArgumentError, ":#{format} is not a valid schema. Valid schemas are: #{FORMATS.join(', ')}." end def schema_name(format) # :nodoc: "#{format}_schema" end - def activerecord_schema(_table_only = false) # :nodoc: + def activerecord_schema(*) # :nodoc: s = "ActiveRecord::Schema.define do\n" s << " create_table \"#{name}\" do |t|\n" columns.each do |column| s << " t.column #{activerecord_schema_definition(column)}" end s << " end\nend" s end - def sequel_schema(table_only = false) # :nodoc: + def sequel_schema(table_only: false) # :nodoc: s = '' s << "Sequel.migration do\n" unless table_only s << " change do\n " unless table_only s << " create_table(:#{name}) do\n" columns.each do |column| @@ -68,11 +68,11 @@ s << " end\n" unless table_only s << "end\n" unless table_only s end - def json_schema(_table_only = false) # :nodoc: + def json_schema(*) # :nodoc: columns.map(&:to_hash).to_json end # ActiveRecord schema definition # @@ -90,12 +90,12 @@ ":#{column.underscored_name}, #{schema_data_type(column, :sequel)}\n" end def schema_data_type(column, format = :activerecord) # :nodoc: case column.type - when *%w[N F I] + when 'N', 'F', 'I' number_data_type(column) - when *%w[Y D T L M B] + when 'Y', 'D', 'T', 'L', 'M', 'B' OTHER_DATA_TYPES[column.type] else string_data_format(format, column) end end