Module: Smplkit::ManagementClient::ResourceShim
- Defined in:
- lib/smplkit/management/client.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.
137 138 139 140 141 |
# File 'lib/smplkit/management/client.rb', line 137 def from_model(model) return {} if model.nil? stringify(model.to_hash) end |
.stringify(value) ⇒ Object
125 126 127 128 129 130 131 132 133 134 |
# File 'lib/smplkit/management/client.rb', line 125 def stringify(value) case value when Hash value.each_with_object({}) { |(k, v), out| out[k.to_s] = stringify(v) } when Array value.map { |v| stringify(v) } else value end end |