Module: MongoDoc::BSON
- Defined in:
- lib/mongo_doc/bson.rb
Constant Summary collapse
- CLASS_KEY =
"json_class"
Class Method Summary collapse
- .array_create(bson_array, options = {}) ⇒ Object
- .bson_create(bson_hash, options = {}) ⇒ Object
- .decode(bson, options = {}) ⇒ Object
Class Method Details
.array_create(bson_array, options = {}) ⇒ Object
26 27 28 29 |
# File 'lib/mongo_doc/bson.rb', line 26 def self.array_create(bson_array, = {}) return bson_array if [:raw_json] bson_array.map {|item| decode(item, )} end |
.bson_create(bson_hash, options = {}) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/mongo_doc/bson.rb', line 19 def self.bson_create(bson_hash, = {}) return bson_hash if [:raw_json] klass = bson_hash.delete(CLASS_KEY) return bson_hash.each_pair {|key, value| bson_hash[key] = decode(value, )} unless klass klass.constantize.bson_create(bson_hash, ) end |