mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
These methods take keyword arguments
This commit is contained in:
parent
1915255846
commit
e1e7fd6c44
7 changed files with 18 additions and 17 deletions
|
@ -1857,7 +1857,7 @@ module ActiveRecord
|
|||
hm_options[k] = options[k] if options.key? k
|
||||
end
|
||||
|
||||
has_many name, scope, hm_options, &extension
|
||||
has_many name, scope, **hm_options, &extension
|
||||
_reflections[name.to_s].parent_reflection = habtm_reflection
|
||||
end
|
||||
end
|
||||
|
|
|
@ -139,7 +139,8 @@ module ActiveRecord
|
|||
|
||||
def add_to(table)
|
||||
columns.each do |column_options|
|
||||
table.column(*column_options)
|
||||
kwargs = column_options.extract_options!
|
||||
table.column(*column_options, **kwargs)
|
||||
end
|
||||
|
||||
if index
|
||||
|
@ -199,7 +200,7 @@ module ActiveRecord
|
|||
# Appends a primary key definition to the table definition.
|
||||
# Can be called multiple times, but this is probably not a good idea.
|
||||
def primary_key(name, type = :primary_key, **options)
|
||||
column(name, type, options.merge(primary_key: true))
|
||||
column(name, type, **options.merge(primary_key: true))
|
||||
end
|
||||
|
||||
##
|
||||
|
@ -226,7 +227,7 @@ module ActiveRecord
|
|||
module_eval <<-RUBY, __FILE__, __LINE__ + 1
|
||||
def #{column_type}(*names, **options)
|
||||
raise ArgumentError, "Missing column name(s) for #{column_type}" if names.empty?
|
||||
names.each { |name| column(name, :#{column_type}, options) }
|
||||
names.each { |name| column(name, :#{column_type}, **options) }
|
||||
end
|
||||
RUBY
|
||||
end
|
||||
|
@ -375,7 +376,7 @@ module ActiveRecord
|
|||
|
||||
index_options = options.delete(:index)
|
||||
index(name, index_options.is_a?(Hash) ? index_options : {}) if index_options
|
||||
@columns_hash[name] = new_column_definition(name, type, options)
|
||||
@columns_hash[name] = new_column_definition(name, type, **options)
|
||||
self
|
||||
end
|
||||
|
||||
|
@ -408,8 +409,8 @@ module ActiveRecord
|
|||
options[:precision] = 6
|
||||
end
|
||||
|
||||
column(:created_at, :datetime, options)
|
||||
column(:updated_at, :datetime, options)
|
||||
column(:created_at, :datetime, **options)
|
||||
column(:updated_at, :datetime, **options)
|
||||
end
|
||||
|
||||
# Adds a reference.
|
||||
|
@ -479,7 +480,7 @@ module ActiveRecord
|
|||
def add_column(name, type, options)
|
||||
name = name.to_s
|
||||
type = type.to_sym
|
||||
@adds << AddColumnDefinition.new(@td.new_column_definition(name, type, options))
|
||||
@adds << AddColumnDefinition.new(@td.new_column_definition(name, type, **options))
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -301,7 +301,7 @@ module ActiveRecord
|
|||
if pk.is_a?(Array)
|
||||
td.primary_keys pk
|
||||
else
|
||||
td.primary_key pk, id, options
|
||||
td.primary_key pk, id, **options
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -785,7 +785,7 @@ module ActiveRecord
|
|||
#
|
||||
# For more information see the {"Transactional Migrations" section}[rdoc-ref:Migration].
|
||||
def add_index(table_name, column_name, options = {})
|
||||
index_name, index_type, index_columns, index_options = add_index_options(table_name, column_name, options)
|
||||
index_name, index_type, index_columns, index_options = add_index_options(table_name, column_name, **options)
|
||||
execute "CREATE #{index_type} INDEX #{quote_column_name(index_name)} ON #{quote_table_name(table_name)} (#{index_columns})#{index_options}"
|
||||
end
|
||||
|
||||
|
@ -1255,7 +1255,7 @@ module ActiveRecord
|
|||
# the PostgreSQL adapter for supporting operator classes.
|
||||
def add_options_for_index_columns(quoted_columns, **options)
|
||||
if supports_index_sort_order?
|
||||
quoted_columns = add_index_sort_order(quoted_columns, options)
|
||||
quoted_columns = add_index_sort_order(quoted_columns, **options)
|
||||
end
|
||||
|
||||
quoted_columns
|
||||
|
@ -1265,7 +1265,7 @@ module ActiveRecord
|
|||
return [column_names] if column_names.is_a?(String)
|
||||
|
||||
quoted_columns = Hash[column_names.map { |name| [name.to_sym, quote_column_name(name).dup] }]
|
||||
add_options_for_index_columns(quoted_columns, options).values
|
||||
add_options_for_index_columns(quoted_columns, **options).values
|
||||
end
|
||||
|
||||
def index_name_for_remove(table_name, options = {})
|
||||
|
|
|
@ -146,7 +146,7 @@ module ActiveRecord
|
|||
|
||||
class SavepointTransaction < Transaction
|
||||
def initialize(connection, savepoint_name, parent_transaction, **options)
|
||||
super(connection, options)
|
||||
super(connection, **options)
|
||||
|
||||
parent_transaction.state.add_child(@state)
|
||||
|
||||
|
|
|
@ -388,7 +388,7 @@ module ActiveRecord
|
|||
def copy_table(from, to, options = {})
|
||||
from_primary_key = primary_key(from)
|
||||
options[:id] = false
|
||||
create_table(to, options) do |definition|
|
||||
create_table(to, **options) do |definition|
|
||||
@definition = definition
|
||||
if from_primary_key.is_a?(Array)
|
||||
@definition.primary_keys from_primary_key
|
||||
|
|
|
@ -103,7 +103,7 @@ module ActiveRecord
|
|||
module ClassMethods
|
||||
def store(store_attribute, options = {})
|
||||
serialize store_attribute, IndifferentCoder.new(store_attribute, options[:coder])
|
||||
store_accessor(store_attribute, options[:accessors], options.slice(:prefix, :suffix)) if options.has_key? :accessors
|
||||
store_accessor(store_attribute, options[:accessors], **options.slice(:prefix, :suffix)) if options.has_key? :accessors
|
||||
end
|
||||
|
||||
def store_accessor(store_attribute, *keys, prefix: nil, suffix: nil)
|
||||
|
|
|
@ -208,8 +208,8 @@ module ActiveRecord
|
|||
# Note that "TRUNCATE" is also a MySQL DDL statement!
|
||||
module ClassMethods
|
||||
# See the ConnectionAdapters::DatabaseStatements#transaction API docs.
|
||||
def transaction(options = {}, &block)
|
||||
connection.transaction(options, &block)
|
||||
def transaction(**options, &block)
|
||||
connection.transaction(**options, &block)
|
||||
end
|
||||
|
||||
def before_commit(*args, &block) # :nodoc:
|
||||
|
|
Loading…
Reference in a new issue