Sha256: 49c11845aef3c57278d807e81a0b5dcd39840ba2741783d19f2aba44558d6d2c

Contents?: true

Size: 611 Bytes

Versions: 3

Compression:

Stored size: 611 Bytes

Contents

module Polyfill
  module V2_4
    module Object
      module Instance
        module Clone
          module Method
            def clone(freeze: true)
              return super() if freeze

              cloned = dup
              (singleton_class.ancestors - self.class.ancestors).drop(1).each do |ancestor|
                cloned.extend(ancestor)
              end
              cloned
            end
          end

          refine ::Object do
            include Method
          end

          def self.included(base)
            base.include Method
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
polyfill-0.6.0 lib/polyfill/v2_4/object/instance/clone.rb
polyfill-0.5.0 lib/polyfill/v2_4/object/instance/clone.rb
polyfill-0.4.0 lib/polyfill/v2_4/object/instance/clone.rb