mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Unify save
method signatures to take keyword arguments
This commit is contained in:
parent
e1e7fd6c44
commit
6d68bb5f69
3 changed files with 8 additions and 8 deletions
|
@ -466,8 +466,8 @@ module ActiveRecord
|
|||
#
|
||||
# Attributes marked as readonly are silently ignored if the record is
|
||||
# being updated.
|
||||
def save(*args, &block)
|
||||
create_or_update(*args, &block)
|
||||
def save(*args, **options, &block)
|
||||
create_or_update(*args, **options, &block)
|
||||
rescue ActiveRecord::RecordInvalid
|
||||
false
|
||||
end
|
||||
|
@ -499,8 +499,8 @@ module ActiveRecord
|
|||
# being updated.
|
||||
#
|
||||
# Unless an error is raised, returns true.
|
||||
def save!(*args, &block)
|
||||
create_or_update(*args, &block) || raise(RecordNotSaved.new("Failed to save the record", self))
|
||||
def save!(*args, **options, &block)
|
||||
create_or_update(*args, **options, &block) || raise(RecordNotSaved.new("Failed to save the record", self))
|
||||
end
|
||||
|
||||
# Deletes the record in the database and freezes this instance to
|
||||
|
|
|
@ -310,11 +310,11 @@ module ActiveRecord
|
|||
with_transaction_returning_status { super }
|
||||
end
|
||||
|
||||
def save(*) #:nodoc:
|
||||
def save(*, **) #:nodoc:
|
||||
with_transaction_returning_status { super }
|
||||
end
|
||||
|
||||
def save!(*) #:nodoc:
|
||||
def save!(*, **) #:nodoc:
|
||||
with_transaction_returning_status { super }
|
||||
end
|
||||
|
||||
|
|
|
@ -43,13 +43,13 @@ module ActiveRecord
|
|||
# The validation context can be changed by passing <tt>context: context</tt>.
|
||||
# The regular {ActiveRecord::Base#save}[rdoc-ref:Persistence#save] method is replaced
|
||||
# with this when the validations module is mixed in, which it is by default.
|
||||
def save(options = {})
|
||||
def save(**options)
|
||||
perform_validations(options) ? super : false
|
||||
end
|
||||
|
||||
# Attempts to save the record just like {ActiveRecord::Base#save}[rdoc-ref:Base#save] but
|
||||
# will raise an ActiveRecord::RecordInvalid exception instead of returning +false+ if the record is not valid.
|
||||
def save!(options = {})
|
||||
def save!(**options)
|
||||
perform_validations(options) ? super : raise_validation_error
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue