Class: Object
- Inherits:
- BasicObject
- Defined in:
- lib/nice/hash/add_to_ruby.rb
Instance Method Summary collapse
-
#deep_symbolize_keys ⇒ Object
symbolize hash of arrays and array of hashes Taken from gist https://gist.github.com/Integralist/9503099 Thanks to @integralist.
-
#in?(array) ⇒ Boolean
include? but the opposite.
Instance Method Details
#deep_symbolize_keys ⇒ Object
symbolize hash of arrays and array of hashes Taken from gist https://gist.github.com/Integralist/9503099 Thanks to @integralist
336 337 338 339 340 341 342 343 344 345 346 347 348 349 |
# File 'lib/nice/hash/add_to_ruby.rb', line 336 def deep_symbolize_keys if is_a? Hash return reduce({}) do |memo, (k, v)| memo.tap { |m| m[k.to_s.to_sym] = v.deep_symbolize_keys } end end if is_a? Array return each_with_object([]) do |v, memo| memo << v.deep_symbolize_keys end end self end |
#in?(array) ⇒ Boolean
include? but the opposite. Check if the object is included on the array
354 355 356 |
# File 'lib/nice/hash/add_to_ruby.rb', line 354 def in?(array) array.include?(self) end |