lib/active_remote/rpc.rb in active_remote-5.1.1 vs lib/active_remote/rpc.rb in active_remote-5.2.0.alpha

- old
+ new

@@ -13,12 +13,12 @@ # Builds an attribute hash that be assigned directly # to an object from an rpc response def build_from_rpc(values) values = values.stringify_keys - attributes.inject({}) do |attributes, (name, definition)| - attributes[name] = definition.from_rpc(values[name]) + attribute_names.inject(_default_attributes.deep_dup) do |attributes, name| + attributes.write_from_database(name, values[name]) attributes end end # Execute an RPC call to the remote service and return the raw response. @@ -51,11 +51,10 @@ ::ActiveRemote::RPCAdapters::ProtobufAdapter end end def assign_attributes_from_rpc(response) - new_attributes = self.class.build_from_rpc(response.to_hash) - @attributes.update(new_attributes) + @attributes = self.class.build_from_rpc(response.to_hash) add_errors(response.errors) if response.respond_to?(:errors) end def remote_call(rpc_method, request_args) self.class.remote_call(rpc_method, request_args)