Sha256: 132f3cb2e5705ef221a986d2558ca43b6d1294688cdcc9f7b8af571edc1d94c2

Contents?: true

Size: 286 Bytes

Versions: 6

Compression:

Stored size: 286 Bytes

Contents

module Declarative
  class DeepDup
    def self.call(args)
      return Array[*dup_items(args)] if args.is_a?(Array)
      return Hash[dup_items(args)] if args.is_a?(Hash)
      args
    end

  private
    def self.dup_items(arr)
      arr.to_a.collect { |v| call(v) }
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
declarative-0.0.9 lib/declarative/deep_dup.rb
declarative-0.0.8 lib/declarative/deep_dup.rb
declarative-0.0.7 lib/declarative/deep_dup.rb
declarative-0.0.6 lib/declarative/deep_dup.rb
declarative-0.0.5 lib/declarative/deep_dup.rb
declarative-0.0.4 lib/declarative/deep_dup.rb