Module: MongoDoc::BSON
- Defined in:
- lib/mongodoc/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
40 41 42 43 |
# File 'lib/mongodoc/bson.rb', line 40 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
33 34 35 36 37 38 |
# File 'lib/mongodoc/bson.rb', line 33 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 |