Class: Object

Inherits:
BasicObject
Defined in:
lib/arachni/ruby/object.rb

Overview

Overloads the Object class providing a #deep_clone method.

Author:

Instance Method Summary collapse

Instance Method Details

#deep_cloneObject

Deep-clones self using a Marshal dump-load.

Returns:

  • (Object)

    Duplicate of self.


18
19
20
# File 'lib/arachni/ruby/object.rb', line 18

def deep_clone
    Marshal.load( Marshal.dump( self ) )
end

#rpc_cloneObject


22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/arachni/ruby/object.rb', line 22

def rpc_clone
    if self.class.respond_to?( :from_rpc_data )
        self.class.from_rpc_data(
            Arachni::RPC::Serializer.serializer.load(
                Arachni::RPC::Serializer.serializer.dump( to_rpc_data_or_self )
            )
        )
    else
        Arachni::RPC::Serializer.serializer.load(
            Arachni::RPC::Serializer.serializer.dump( self )
        )
    end
end

#to_rpc_data_or_selfObject


36
37
38
# File 'lib/arachni/ruby/object.rb', line 36

def to_rpc_data_or_self
    respond_to?( :to_rpc_data ) ? to_rpc_data : self
end