Sha256: 3e137baa718c6fae2cc4a41d59fd1c3a07960f56079e0182b7611fd0ebb4e24d

Contents?: true

Size: 300 Bytes

Versions: 15

Compression:

Stored size: 300 Bytes

Contents

class Hash
  # Merges defaults with the hash
  def with_defaults(defaults)
    self.merge(defaults) { |key,old,new| old.nil? ? new : old }
  end

  # Merges defaults with the hash (destructive)
  def with_defaults!(defaults)
    self.merge!(defaults) { |key,old,new| old.nil? ? new : old }
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
darkhelmet-darkext-0.0.2 lib/darkext/hash.rb
darkhelmet-darkext-0.0.3 lib/darkext/hash.rb
darkhelmet-darkext-0.1.0 lib/darkext/hash.rb
darkhelmet-darkext-0.2.0 lib/darkext/hash.rb
darkhelmet-darkext-0.3.0 lib/darkext/hash.rb
darkhelmet-darkext-0.3.1 lib/darkext/hash.rb
darkhelmet-darkext-0.3.2 lib/darkext/hash.rb
darkhelmet-darkext-0.4.0 lib/darkext/hash.rb
darkhelmet-darkext-0.4.1 lib/darkext/hash.rb
darkhelmet-darkext-0.4.2 lib/darkext/hash.rb
darkhelmet-darkext-0.4.3 lib/darkext/hash.rb
darkhelmet-darkext-0.5.0 lib/darkext/hash.rb
darkhelmet-darkext-0.5.1 lib/darkext/hash.rb
darkhelmet-darkext-0.5.2 lib/darkext/hash.rb
darkhelmet-darkext-0.5.3 lib/darkext/hash.rb