Sha256: 99b1b75ed057d6dec8ecef933a861664482228ee35c3a1bb0d70a1253a579cba

Contents?: true

Size: 855 Bytes

Versions: 32

Compression:

Stored size: 855 Bytes

Contents

# Overloads the {Object} class providing a {#deep_clone} method.
#
# @author Tasos "Zapotek" Laskos <tasos.laskos@gmail.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(
                Cuboid::RPC::Serializer.serializer.load(
                    Cuboid::RPC::Serializer.serializer.dump( to_rpc_data )
                )
            )
        else
            Cuboid::RPC::Serializer.serializer.load(
                Cuboid::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

32 entries across 32 versions & 1 rubygems

Version Path
cuboid-0.2.11 lib/cuboid/ruby/object.rb
cuboid-0.2.10 lib/cuboid/ruby/object.rb
cuboid-0.2.9 lib/cuboid/ruby/object.rb
cuboid-0.2.8 lib/cuboid/ruby/object.rb
cuboid-0.2.7 lib/cuboid/ruby/object.rb
cuboid-0.2.6 lib/cuboid/ruby/object.rb
cuboid-0.2.5 lib/cuboid/ruby/object.rb
cuboid-0.2.4.2 lib/cuboid/ruby/object.rb
cuboid-0.2.4.1 lib/cuboid/ruby/object.rb
cuboid-0.2.4 lib/cuboid/ruby/object.rb
cuboid-0.2.3 lib/cuboid/ruby/object.rb
cuboid-0.2.2 lib/cuboid/ruby/object.rb
cuboid-0.2.1 lib/cuboid/ruby/object.rb
cuboid-0.2 lib/cuboid/ruby/object.rb
cuboid-0.1.9.1 lib/cuboid/ruby/object.rb
cuboid-0.1.9 lib/cuboid/ruby/object.rb
cuboid-0.1.8 lib/cuboid/ruby/object.rb
cuboid-0.1.7 lib/cuboid/ruby/object.rb
cuboid-0.1.6.1 lib/cuboid/ruby/object.rb
cuboid-0.1.6 lib/cuboid/ruby/object.rb