Sha256: eb3ee6f72978613534b0d3f6844b0463e0b54de57d49bb7f64af74bbbee01495

Contents?: true

Size: 1.14 KB

Versions: 2

Compression:

Stored size: 1.14 KB

Contents

=begin
    Copyright 2010-2017 Sarosys LLC <http://www.sarosys.com>

    This file is part of the Arachni Framework project and is subject to
    redistribution and commercial restrictions. Please see the Arachni Framework
    web site for more information on licensing and terms of use.
=end

# Overloads the {Object} class providing a {#deep_clone} method.
#
# @author Tasos "Zapotek" Laskos <tasos.laskos@arachni-scanner.com>
class Object

    # Deep-clones self using a Marshal dump-load.
    #
    # @return   [Object]
    #   Duplicate of self.
    def deep_clone
        Marshal.load( Marshal.dump( self ) )
    end

    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

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

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
arachni-1.5.1 lib/arachni/ruby/object.rb
arachni-1.5 lib/arachni/ruby/object.rb