Module: ActiveRemote::RPC

Included in:
Base
Defined in:
lib/active_remote/rpc.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



5
6
7
8
9
10
# File 'lib/active_remote/rpc.rb', line 5

def self.included(klass)
  klass.class_eval do
    extend ::ActiveRemote::RPC::ClassMethods
    include ::ActiveRemote::Serializers::Protobuf
  end
end

Instance Method Details

#execute(rpc_method, request_args) ⇒ Object

Invoke an RPC call to the service for the given rpc method.



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/active_remote/rpc.rb', line 39

def execute(rpc_method, request_args)
  @last_request = request(rpc_method, request_args)

  _service_class.client.__send__(rpc_method, @last_request) do |c|

    # In the event of service failure, raise the error.
    c.on_failure do |error|
      raise ActiveRemoteError, error.message
    end

    # In the event of service success, assign the response.
    c.on_success do |response|
      @last_response = response
    end
  end
end

#remote_call(rpc_method, request_args) ⇒ Object

Execute an RPC call to the remote service and return the raw response.



58
59
60
61
# File 'lib/active_remote/rpc.rb', line 58

def remote_call(rpc_method, request_args)
  self.execute(rpc_method, request_args)
  self.last_response
end