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.



21
22
23
24
# File 'lib/dizby/distributed/object.rb', line 21

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)



44
45
46
47
48
# File 'lib/dizby/distributed/object.rb', line 44

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)



13
14
15
# File 'lib/dizby/distributed/object.rb', line 13

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

Instance Method Details

#_dump(_)



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

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

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

Returns:

  • (Boolean)


29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/dizby/distributed/object.rb', line 29

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