Class: EMRPC::MethodProxy

Inherits:
BlankSlate show all
Defined in:
lib/emrpc/blocking_api/method_proxy.rb

Overview

Sends all the messages to a specified backend FIXME: deal with Object’s methods gracefully.

Constant Summary collapse

EMPTY_ARGS =
[ ].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(backend) ⇒ MethodProxy

Returns a new instance of MethodProxy.



8
9
10
# File 'lib/emrpc/blocking_api/method_proxy.rb', line 8

def initialize(backend)
  @__emrpc_backend = backend
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args, &blk) ⇒ Object



12
13
14
# File 'lib/emrpc/blocking_api/method_proxy.rb', line 12

def method_missing(meth, *args, &blk)
  @__emrpc_backend.send(meth, *args, &blk)
end

Instance Attribute Details

#__emrpc_backendObject (readonly)

Returns the value of attribute __emrpc_backend.



7
8
9
# File 'lib/emrpc/blocking_api/method_proxy.rb', line 7

def __emrpc_backend
  @__emrpc_backend
end

Instance Method Details

#classObject

alias :__class__ :class



37
38
39
# File 'lib/emrpc/blocking_api/method_proxy.rb', line 37

def class
  @__emrpc_backend.send(:class)
end

#idObject



16
17
18
# File 'lib/emrpc/blocking_api/method_proxy.rb', line 16

def id
  @__emrpc_backend.send(:id)
end

#inspectObject



52
53
54
# File 'lib/emrpc/blocking_api/method_proxy.rb', line 52

def inspect
  "#<MethodProxy:0x#{__id__.to_s(16)} remote:#{@__emrpc_backend.send(:inspect)}>"
end

#is_a?(type) ⇒ Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/emrpc/blocking_api/method_proxy.rb', line 32

def is_a?(type)
  @__emrpc_backend.send(:is_a?, type)
end

#marshal_dumpObject

Marshalling - just return a backend



43
44
45
# File 'lib/emrpc/blocking_api/method_proxy.rb', line 43

def marshal_dump
  @__emrpc_backend
end

#marshal_load(data) ⇒ Object



47
48
49
# File 'lib/emrpc/blocking_api/method_proxy.rb', line 47

def marshal_load(data)
  initialize(data)
end

#to_iObject



20
21
22
# File 'lib/emrpc/blocking_api/method_proxy.rb', line 20

def to_i
  @__emrpc_backend.send(:to_i)
end

#to_sObject



24
25
26
# File 'lib/emrpc/blocking_api/method_proxy.rb', line 24

def to_s
  @__emrpc_backend.send(:to_s)
end

#to_strObject



28
29
30
# File 'lib/emrpc/blocking_api/method_proxy.rb', line 28

def to_str
  @__emrpc_backend.send(:to_str)
end