Sha256: 388fc633dc3f9ef3f5b26f01dbff2296d669c28013922c1d80c6db9cc8f392a7
Contents?: true
Size: 758 Bytes
Versions: 2
Compression:
Stored size: 758 Bytes
Contents
module Hirb module Util extend self # Returns a constant like const_get() no matter what namespace it's nested in. # Returns nil if the constant is not found. def any_const_get(name) return name if name.is_a?(Module) begin klass = Object name.split('::').each {|e| klass = klass.const_get(e) } klass rescue nil end end # Recursively merge hash1 with hash2. def recursive_hash_merge(hash1, hash2) hash1.merge(hash2) {|k,o,n| (o.is_a?(Hash)) ? recursive_hash_merge(o,n) : n} end # from Rails ActiveSupport def camelize(string) string.to_s.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase } end end end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
cldwalker-hirb-0.1.2 | lib/hirb/util.rb |
hirb-0.1.2 | lib/hirb/util.rb |