lib/mongo_mapper/plugins/serialization.rb in mongo_mapper-0.8.3 vs lib/mongo_mapper/plugins/serialization.rb in mongo_mapper-0.8.4

- old
+ new

@@ -50,19 +50,19 @@ hash.each do |key, value| if value.is_a?(Array) hash[key] = value.map do |item| item.respond_to?(:as_json) ? item.as_json(options) : item end - elsif value.is_a? BSON::ObjectID + elsif value.is_a? BSON::ObjectId hash[key] = value.to_s elsif value.respond_to?(:as_json) hash[key] = value.as_json(options) end end # Replicate Rails 3 naming - and also bin anytihng after : for use in our dynamic classes from unit tests - hash = { ActiveSupport::Inflector.underscore(ActiveSupport::Inflector.demodulize(self)).gsub(/:.*/,'') => hash } if include_root_in_json + hash = { ActiveSupport::Inflector.underscore(ActiveSupport::Inflector.demodulize(self.class.name)).gsub(/:.*/,'') => hash } if include_root_in_json hash end end module ClassMethods @@ -71,6 +71,6 @@ end end end end -end \ No newline at end of file +end