Module: Smplkit::ApiSupport::ResourceShim
- Defined in:
- lib/smplkit/api_support.rb
Overview
Deep-stringify Hash keys so resources returned by generated to_hash (symbol-keyed) match what the wrapper helpers expect (string-keyed).
Class Method Summary collapse
-
.from_model(model) ⇒ Object
Convenience: produce a string-keyed Hash from a generated model.
- .stringify(value) ⇒ Object
Class Method Details
.from_model(model) ⇒ Object
Convenience: produce a string-keyed Hash from a generated model.
76 77 78 79 80 |
# File 'lib/smplkit/api_support.rb', line 76 def from_model(model) return {} if model.nil? stringify(model.to_hash) end |
.stringify(value) ⇒ Object
71 72 73 |
# File 'lib/smplkit/api_support.rb', line 71 def stringify(value) Smplkit::Helpers.deep_stringify_keys(value) end |