File: utils.rb

package info (click to toggle)
ruby-pdf-core 0.10.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 408 kB
  • sloc: ruby: 2,270; makefile: 4
file content (21 lines) | stat: -rw-r--r-- 510 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# frozen_string_literal: true

module PDF
  module Core
    # Utility methods
    module Utils
      module_function

      # Deep clone an object.
      # It uses marshal-demarshal trick. Since it's supposed to be use only on
      # objects that can be serialized into PDF it shouldn't have any issues
      # with objects that can not be marshaled.
      #
      # @param object [any]
      # @return [any]
      def deep_clone(object)
        Marshal.load(Marshal.dump(object))
      end
    end
  end
end