lib/active_remote/persistence.rb in active_remote-7.0.0 vs lib/active_remote/persistence.rb in active_remote-7.1.0
- old
+ new
@@ -26,11 +26,11 @@
# the record error messages indicating what went wrong.
#
# The newly created record is returned if it was successfully saved or not.
#
def create(attributes)
- remote = self.new(attributes)
+ remote = new(attributes)
remote.save
remote
end
# Creates a remote record through the service and if successful, returns
@@ -38,21 +38,21 @@
#
# The service will run any validations and if any of them fail, will raise
# an ActiveRemote::RemoteRecordNotSaved exception.
#
def create!(attributes)
- remote = self.new(attributes)
+ remote = new(attributes)
remote.save!
remote
end
# Instantiate a record with the given remote attributes. Generally used
# when retrieving records that already exist, so @new_record is set to false.
#
def instantiate(new_attributes = {}, options = {})
- attributes = self.build_from_rpc(new_attributes)
- new_object = self.allocate.init_with(attributes)
+ attributes = build_from_rpc(new_attributes)
+ new_object = allocate.init_with(attributes)
new_object.readonly! if options[:readonly]
new_object
end
@@ -218,12 +218,12 @@
# attribute is marked as readonly.
def update_attribute(name, value)
raise ReadOnlyRemoteRecord if readonly?
name = name.to_s
- send("#{name}=", value)
- save(:validate => false)
+ send(:"#{name}=", value)
+ save(validate: false)
end
# Updates the attributes of the remote record from the passed-in hash and
# saves the remote record. If the object is invalid, it will have error
# messages and false will be returned.
@@ -242,10 +242,10 @@
assign_attributes(attributes)
save!
end
alias_method :update!, :update_attributes!
- private
+ private
# Handles creating a remote object and serializing it's attributes and
# errors from the response.
#
def remote_create