Sha256: 4708d85c8579ac991a33f2aff2e493939ed64297715e8cb17fc9d20b8a6c5a92
Contents?: true
Size: 723 Bytes
Versions: 2
Compression:
Stored size: 723 Bytes
Contents
module HashHelper # -------- # # - Hash - # # -------- # # Returns a specific value from the given hash (or the default value if not set). def get_value(key, hash, default_value = nil) value = hash.delete key value = default_value if value.nil? and !default_value.nil? value end # Removes and returns a specific value from the given hash (or the default value if not set). def pop_value(key, hash, default_value = nil) symbolize_keys hash unless hash.empty? get_value key.to_sym, hash, default_value end # all keys of the given hash symbolize. def symbolize_keys(hash) result = {} hash.each { |key, value| result[key.to_sym] = value } hash.replace result end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
andy_rails_toolbox-1.1.1 | app/helpers/hash_helper.rb |
andy_rails_toolbox-1.1.0 | app/helpers/hash_helper.rb |