Sha256: ea2ad30c33951c49ea1a698b485ebb5aa4f300dcbf587fb8cf889bc2fabfb4fb

Contents?: true

Size: 369 Bytes

Versions: 82

Compression:

Stored size: 369 Bytes

Contents

class Hash 
  def limit_to_keys(limit_keys)
    dup.limit_to_keys!(limit_keys)
  end

  def limit_to_keys!(limit_keys)
    keys.each { |key| delete(key) unless limit_keys.include? key }
    self
  end

  def soft_delete(key)
    cloned_hash = deep_clone
    cloned_hash.delete(key)
    cloned_hash
  end

  def deep_clone
    Marshal::load(Marshal.dump(self))
  end
end

Version data entries

82 entries across 82 versions & 1 rubygems

Version Path
fossil-0.4.26 lib/hash_extentions.rb
fossil-0.4.25 lib/hash_extentions.rb
fossil-0.4.24 lib/hash_extentions.rb
fossil-0.4.23 lib/hash_extentions.rb
fossil-0.4.22 lib/hash_extentions.rb
fossil-0.4.20 lib/hash_extentions.rb
fossil-0.4.19 lib/hash_extentions.rb
fossil-0.4.18 lib/hash_extentions.rb
fossil-0.4.17 lib/hash_extentions.rb
fossil-0.4.16 lib/hash_extentions.rb
fossil-0.4.15 lib/hash_extentions.rb
fossil-0.4.14 lib/hash_extentions.rb
fossil-0.4.13 lib/hash_extentions.rb
fossil-0.4.12 lib/hash_extentions.rb
fossil-0.4.10 lib/hash_extentions.rb
fossil-0.4.9 lib/hash_extentions.rb
fossil-0.4.8 lib/hash_extentions.rb
fossil-0.4.7 lib/hash_extentions.rb
fossil-0.4.6 lib/hash_extentions.rb
fossil-0.4.5 lib/hash_extentions.rb