Class: Dizby::DistributedObject

Inherits:
Object
  • Object
show all
Defined in:
lib/dizby/distributed/object.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(obj, server) ⇒ DistributedObject

Returns a new instance of DistributedObject.


15
16
17
18
# File 'lib/dizby/distributed/object.rb', line 15

def initialize(obj, server)
  @obj = obj
  @server = server
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(msg_id, *args, &block)


38
39
40
41
42
# File 'lib/dizby/distributed/object.rb', line 38

def method_missing(msg_id, *args, &block)
  @server.log.debug("calling: #{msg_id} #{args.join ', '}")
  Dizby.check_insecure_method(@obj, msg_id)
  @obj.__send__(msg_id, *args, &block)
end

Class Method Details

._load(str)


7
8
9
# File 'lib/dizby/distributed/object.rb', line 7

def self._load(str)
  SemiObjectProxy.new(*Marshal.load(str))
end

Instance Method Details

#_dump(_)


11
12
13
# File 'lib/dizby/distributed/object.rb', line 11

def _dump(_)
  Marshal.dump [@server.uri, @server.to_id(@obj)]
end

#respond_to?(msg_id, priv = false) ⇒ Boolean

Returns:

  • (Boolean)

23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/dizby/distributed/object.rb', line 23

def respond_to?(msg_id, priv = false)
  responds =
    case msg_id
    when :_dump
      true
    when :marshal_dump
      false
    else
      method_missing(:respond_to?, msg_id, priv)
    end

  @server.log.debug("respond_to?(#{msg_id}) => #{responds}")
  responds
end