Sha256: d676c8ed8e2a58e86ec62a505437209616da1d30ef7fbd1012bb9cee1d1d28b0

Contents?: true

Size: 773 Bytes

Versions: 1

Compression:

Stored size: 773 Bytes

Contents

require 'ruby_wings/version'


# Make access to hash values easier
class ::NilClass
  def blank?
    true
  end
end

class ::String
  def blank?
    empty?
  end
end

class ::Fixnum
  def blank?
    false
  end
end

# Allow recursive merging of Hashes
# thanks to http://stackoverflow.com/a/25990044
class ::Hash
  def deep_merge(second)
    merger = proc do |key, v1, v2|
      if Hash === v1 && Hash === v2
        v1.merge(v2, &merger)
      else
        [:undefined, nil, :nil].include?(v2) ? v1 : v2
      end
    end
    self.merge(second, &merger)
  end

  def symbolize
    Hash[
      self.map do |k, v|
        [(k.respond_to?(:to_sym) ? k.to_sym : k), v.class == Hash ? v.symbolize : v]
      end
    ]
  end
end

module RubyWings
  # Your code goes here...
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ruby_wings-0.1.1 lib/ruby_wings.rb