class Array
Adds a few extra methods to the standard Hash
Public Instance Methods
remove_nil_values!()
click to toggle source
Removes all nil values from the hash. If the value is an array or hash, it will do this recursively.
# File lib/screenplay/datatype-extensions.rb, line 84 def remove_nil_values! self.compact! self.each { |val| val.remove_nil_values! if (val.is_a?(Hash) || val.is_a?(Array)) } end
stringify_keys!(recursive = true)
click to toggle source
Changes all keys to strings. If the value is an array or hash, it will do this recursively.
# File lib/screenplay/datatype-extensions.rb, line 95 def stringify_keys!(recursive = true) self.map! { |val| val.stringify_keys! if (recursive && (val.is_a?(Hash) || val.is_a?(Array))); val } end
symbolize_keys!(recursive = true)
click to toggle source
Changes all keys to symbols. If the value is an array or hash, it will do this recursively.
# File lib/screenplay/datatype-extensions.rb, line 90 def symbolize_keys!(recursive = true) self.map! { |val| val.symbolize_keys! if (recursive && (val.is_a?(Hash) || val.is_a?(Array))); val } end