lib/active_remote/rpc.rb in active_remote-2.0.0.rc1 vs lib/active_remote/rpc.rb in active_remote-2.0.0.rc2
- old
+ new
@@ -1,9 +1,15 @@
+require 'active_remote/serializers/protobuf'
+
module ActiveRemote
module RPC
extend ActiveSupport::Concern
+ included do
+ include Serializers::Protobuf
+ end
+
module ClassMethods
# Execute an RPC call to the remote service and return the raw response.
#
def remote_call(rpc_method, request_args)
@@ -15,10 +21,12 @@
# Return a protobuf request object for the given rpc request.
#
def request(rpc_method, request_args)
return request_args unless request_args.is_a?(Hash)
- request_type(rpc_method).new(request_args)
+ message_class = request_type(rpc_method)
+ fields = fields_from_attributes(message_class, request_args)
+ message_class.new(fields)
end
# Return the class applicable to the request for the given rpc method.
#
def request_type(rpc_method)