Class: Hash
- Inherits:
-
Object
- Object
- Hash
- Defined in:
- lib/ky/hash.rb
Overview
specifically for HashWithIndifferentAccess < Hash, instead of plain to_yaml
Instance Method Summary collapse
- #to_hash_recursive ⇒ Object
-
#to_plain_yaml(opts = {}) ⇒ Object
which yields ugly !map:ActiveSupport::HashWithIndifferentAccess.
Instance Method Details
#to_hash_recursive ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/ky/hash.rb', line 6 def to_hash_recursive result = self.to_h result.each do |key, value| if(value.kind_of? Hash) result[key] = value.to_hash_recursive.to_h elsif (value.kind_of? Array) result[key] = value.map { |item| item.kind_of?(Hash) ? item.to_hash_recursive : item } end end result end |
#to_plain_yaml(opts = {}) ⇒ Object
which yields ugly !map:ActiveSupport::HashWithIndifferentAccess
2 3 4 |
# File 'lib/ky/hash.rb', line 2 def to_plain_yaml(opts = {}) # which yields ugly !map:ActiveSupport::HashWithIndifferentAccess self.to_hash_recursive.to_yaml(opts) end |