Module: Hsdq::Utilities
- Included in:
- Hsdq
- Defined in:
- lib/hsdq/utilities.rb
Instance Method Summary collapse
-
#deep_symbolize(a_hash) ⇒ Hash
utility method to symbolize the keys of a hash.
-
#snakify(string) ⇒ String
utility method (equivalent to Rails underscore).
Instance Method Details
#deep_symbolize(a_hash) ⇒ Hash
utility method to symbolize the keys of a hash
8 9 10 |
# File 'lib/hsdq/utilities.rb', line 8 def deep_symbolize(a_hash) JSON.parse(JSON[a_hash], symbolize_names: true) end |
#snakify(string) ⇒ String
utility method (equivalent to Rails underscore)
15 16 17 |
# File 'lib/hsdq/utilities.rb', line 15 def snakify(string) string.split(/(?=[A-Z])/).map(&:downcase).join('_') end |