Sha256: 743fcf66c948495215f407a01e58458648477998f56e45a4c5178baf9f192601

Contents?: true

Size: 929 Bytes

Versions: 1

Compression:

Stored size: 929 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

if 1.is_a? Integer
  class ::Integer
    def blank?
      false
    end
  end
else
  class ::Fixnum
    def blank?
      false
    end
  end

  class ::Bignum
    def blank?
      false
    end
  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.2.0 lib/ruby_wings.rb