Method: Megam::JSONCompat.map_to_rb_obj
- Defined in:
- lib/megam/core/json_compat.rb
.map_to_rb_obj(json_obj) ⇒ Object
Look at an object that’s a basic type (from json parse) and convert it to an instance of Megam classes if desired.
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/megam/core/json_compat.rb', line 107 def map_to_rb_obj(json_obj) case json_obj when Hash mapped_hash = map_hash_to_rb_obj(json_obj) if json_obj.has_key?(JSON_CLAZ) && (class_to_inflate = class_for_json_class(json_obj[JSON_CLAZ])) class_to_inflate.json_create(mapped_hash) else mapped_hash end when Array json_obj.map {|e| map_to_rb_obj(e)} else json_obj end end |