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.3 lib/hash_extentions.rb
fossil-0.4.2 lib/hash_extentions.rb
fossil-0.4.1 lib/hash_extentions.rb
fossil-0.4.0 lib/hash_extentions.rb
fossil-0.3.49 lib/hash_extentions.rb
fossil-0.3.48 lib/hash_extentions.rb
fossil-0.3.47 lib/hash_extentions.rb
fossil-0.3.46 lib/hash_extentions.rb
fossil-0.3.45 lib/hash_extentions.rb
fossil-0.3.44 lib/hash_extentions.rb
fossil-0.3.43 lib/hash_extentions.rb
fossil-0.3.42 lib/hash_extentions.rb
fossil-0.3.41 lib/hash_extentions.rb
fossil-0.3.40 lib/hash_extentions.rb
fossil-0.3.39 lib/hash_extentions.rb
fossil-0.3.38 lib/hash_extentions.rb
fossil-0.3.37 lib/hash_extentions.rb
fossil-0.3.36 lib/hash_extentions.rb
fossil-0.3.35 lib/hash_extentions.rb
fossil-0.3.34 lib/hash_extentions.rb