lib/acfs/resource/persistence.rb in acfs-1.5.1 vs lib/acfs/resource/persistence.rb in acfs-1.6.0
- old
+ new
@@ -55,12 +55,12 @@
#
# @return [Boolean] True if save operation was successful,
# false otherwise.
# @see #save! See {#save!} for available options.
#
- def save(*args)
- save!(*args)
+ def save(**opts)
+ save!(**opts)
true
rescue Acfs::Error
false
end
@@ -80,14 +80,14 @@
# @raise [Acfs::ErroneousResponse]
# If remote service respond with not successful response.
#
# @see #save
#
- def save!(opts = {})
+ def save!(**opts)
opts[:data] = attributes unless opts[:data]
- operation((new? ? :create : :update), opts) do |data|
+ operation((new? ? :create : :update), **opts) do |data|
update_with data
end
rescue ::Acfs::InvalidResource => e
self.remote_errors = e.errors
raise e
@@ -107,15 +107,15 @@
#
# @see #save
# @see #attributes=
# @see #update_attributes!
#
- def update_attributes(attrs, opts = {})
- check_loaded! opts
+ def update_attributes(attrs, **opts)
+ check_loaded!(**opts)
self.attributes = attrs
- save opts
+ save(**opts)
end
# @api public
#
# Update attributes with given data and save resource.
@@ -134,15 +134,15 @@
#
# @see #save!
# @see #attributes=
# @see #update_attributes
#
- def update_attributes!(attrs, opts = {})
+ def update_attributes!(attrs, **opts)
check_loaded! opts
self.attributes = attrs
- save! opts
+ save!(**opts)
end
# @api public
#
# Destroy resource by sending a DELETE request.
@@ -150,12 +150,12 @@
# Deleting a resource is a synchronous operation.
#
# @return [Boolean]
# @see #delete!
#
- def delete(opts = {})
- delete! opts
+ def delete(**opts)
+ delete!(**opts)
true
rescue Acfs::Error
false
end
@@ -170,14 +170,14 @@
# If remote service respond with not successful response.
#
# @return [undefined]
# @see #delete
#
- def delete!(opts = {})
+ def delete!(**opts)
opts[:params] ||= {}
opts[:params] = attributes_for_url(:delete).merge opts[:params]
- operation :delete, opts do |data|
+ operation(:delete, **opts) do |data|
update_with data
freeze
end
end