diff --git a/lib/src/http/services/memory.dart b/lib/src/http/services/memory.dart index 987c5a76..d2135b7b 100644 --- a/lib/src/http/services/memory.dart +++ b/lib/src/http/services/memory.dart @@ -26,9 +26,10 @@ class MemoryService extends Service { } else throw new AngelHttpException.NotFound(); } - Future create(Map data, [Map params]) async { + Future create(data, [Map params]) async { try { - items[items.length] = god.deserializeFromMap(data, T); + items[items.length] = + (data is Map) ? god.deserializeFromMap(data, T) : data; T created = items[items.length - 1]; return makeJson(items.length - 1, created); } catch (e) { @@ -36,13 +37,14 @@ class MemoryService extends Service { } } - Future modify(id, Map data, [Map params]) async { + Future modify(id, data, [Map params]) async { int desiredId = int.parse(id.toString()); if (items.containsKey(desiredId)) { try { Map existing = god.serializeToMap(items[desiredId]); data = mergeMap([existing, data]); - items[desiredId] = god.deserializeFromMap(data, T); + items[desiredId] = + (data is Map) ? god.deserializeFromMap(data, T) : data; return makeJson(desiredId, items[desiredId]); } catch (e) { throw new AngelHttpException.BadRequest(message: 'Invalid data.'); @@ -50,11 +52,12 @@ class MemoryService extends Service { } else throw new AngelHttpException.NotFound(); } - Future update(id, Map data, [Map params]) async { + Future update(id, data, [Map params]) async { int desiredId = int.parse(id.toString()); if (items.containsKey(desiredId)) { try { - items[desiredId] = god.deserializeFromMap(data, T); + items[desiredId] = + (data is Map) ? god.deserializeFromMap(data, T) : data; return makeJson(desiredId, items[desiredId]); } catch (e) { throw new AngelHttpException.BadRequest(message: 'Invalid data.'); diff --git a/pubspec.yaml b/pubspec.yaml index 48fabb46..68701c2f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: angel_framework -version: 0.0.0-dev.15 +version: 0.0.0-dev.16 description: Core libraries for the Angel framework. author: Tobe O homepage: https://github.com/angel-dart/angel_framework