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
|
# Attributes marked as readonly are silently ignored if the record is
|
||||||
# being updated.
|
# being updated.
|
||||||
def save(*args, &block)
|
def save(*args, **options, &block)
|
||||||
create_or_update(*args, &block)
|
create_or_update(*args, **options, &block)
|
||||||
rescue ActiveRecord::RecordInvalid
|
rescue ActiveRecord::RecordInvalid
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
@ -499,8 +499,8 @@ module ActiveRecord
|
||||||
# being updated.
|
# being updated.
|
||||||
#
|
#
|
||||||
# Unless an error is raised, returns true.
|
# Unless an error is raised, returns true.
|
||||||
def save!(*args, &block)
|
def save!(*args, **options, &block)
|
||||||
create_or_update(*args, &block) || raise(RecordNotSaved.new("Failed to save the record", self))
|
create_or_update(*args, **options, &block) || raise(RecordNotSaved.new("Failed to save the record", self))
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deletes the record in the database and freezes this instance to
|
# Deletes the record in the database and freezes this instance to
|
||||||
|
|
|
@ -310,11 +310,11 @@ module ActiveRecord
|
||||||
with_transaction_returning_status { super }
|
with_transaction_returning_status { super }
|
||||||
end
|
end
|
||||||
|
|
||||||
def save(*) #:nodoc:
|
def save(*, **) #:nodoc:
|
||||||
with_transaction_returning_status { super }
|
with_transaction_returning_status { super }
|
||||||
end
|
end
|
||||||
|
|
||||||
def save!(*) #:nodoc:
|
def save!(*, **) #:nodoc:
|
||||||
with_transaction_returning_status { super }
|
with_transaction_returning_status { super }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -43,13 +43,13 @@ module ActiveRecord
|
||||||
# The validation context can be changed by passing <tt>context: context</tt>.
|
# The validation context can be changed by passing <tt>context: context</tt>.
|
||||||
# The regular {ActiveRecord::Base#save}[rdoc-ref:Persistence#save] method is replaced
|
# 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.
|
# 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
|
perform_validations(options) ? super : false
|
||||||
end
|
end
|
||||||
|
|
||||||
# Attempts to save the record just like {ActiveRecord::Base#save}[rdoc-ref:Base#save] but
|
# 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.
|
# 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
|
perform_validations(options) ? super : raise_validation_error
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue