From 0f04a2b88746b15e4ad41e44b39b5e89bf7bc479 Mon Sep 17 00:00:00 2001 From: atreeon Date: Mon, 27 Nov 2023 17:28:36 +0000 Subject: [PATCH] Updated readme --- example/test/readme_test.dart | 12 ++++++------ morphy/CHANGELOG.md | 3 +++ morphy/README.md | 17 ++++++++++------- morphy/pubspec.yaml | 8 ++++---- 4 files changed, 23 insertions(+), 17 deletions(-) diff --git a/example/test/readme_test.dart b/example/test/readme_test.dart index 0c94d77..f594e1e 100644 --- a/example/test/readme_test.dart +++ b/example/test/readme_test.dart @@ -191,24 +191,24 @@ main() { }); test("16 Json polymorphism", () { - var toJsonAs = [ + var xObjects = [ X(val: "x"), Y(val: "xy", valY: 1), Z(val: "xyz", valY: 2, valZ: 4.34), ]; - var result = toJsonAs.map((e) => e.toJson_2({})).toList(); + var resultInJsonFormat = xObjects.map((e) => e.toJson_2({})).toList(); - var resultJson = [ + var expectedJson = [ {'val': 'x', '_className_': 'X'}, {'val': 'xy', 'valY': 1, '_className_': 'Y'}, {'val': 'xyz', 'valY': 2, 'valZ': 4.34, '_className_': 'Z'} ]; - expect(result, resultJson); + expect(resultInJsonFormat, expectedJson); - var resultObjects = resultJson.map((e) => X.fromJson(e)).toList(); + var resultXObjects = expectedJson.map((e) => X.fromJson(e)).toList(); - expect(resultObjects, toJsonAs); + expect(resultXObjects, xObjects); }); } diff --git a/morphy/CHANGELOG.md b/morphy/CHANGELOG.md index 4a1b581..282f44c 100644 --- a/morphy/CHANGELOG.md +++ b/morphy/CHANGELOG.md @@ -1,2 +1,5 @@ +## 1.0.0+1 +- Updated documentation + ## 1.0.0 - First published version \ No newline at end of file diff --git a/morphy/README.md b/morphy/README.md index 348b49c..3867c49 100644 --- a/morphy/README.md +++ b/morphy/README.md @@ -201,29 +201,29 @@ The subtypes must be specified in the explicitSubTypes and in the correct order double get valZ; } - var toJsonAs = [ + var xObjects = [ X(val: "x"), Y(val: "xy", valY: 1), Z(val: "xyz", valY: 2, valZ: 4.34), ]; -We can then just convert our list of A objects to JSON preserving their original type. +We can then just convert our list of X objects to JSON preserving their original type. - var result = toJsonAs.map((e) => e.toJson_2({})).toList(); + var resultInJsonFormat = xObjects.map((e) => e.toJson_2({})).toList(); - var resultJson = [ + var expectedJson = [ {'val': 'x', '_className_': 'X'}, {'val': 'xy', 'valY': 1, '_className_': 'Y'}, {'val': 'xyz', 'valY': 2, 'valZ': 4.34, '_className_': 'Z'} ]; - expect(result, resultJson); + expect(resultInJsonFormat, expectedJson); and then convert them back again, continuing to preserve their original type - var resultObjects = resultJson.map((e) => X.fromJson(e)).toList(); + var resultXObjects = expectedJson.map((e) => X.fromJson(e)).toList(); - expect(resultObjects, toJsonAs); + expect(resultXObjects, xObjects); Also generics work and more complicated inheritance hierarchies. (see the tests ex52 in the example folder) @@ -231,6 +231,9 @@ Also generics work and more complicated inheritance hierarchies. (see the tests We also allow multiple inheritance. + @Morphy(generateJson: true) + abstract class $FrankensteinsDogCat implements $Dog, $Cat {} + var frankie = FrankensteinsDogCat(whiskerLength: 13.75, woofSound: "rowf", name: "frankie", age: 1); expect(frankie is Cat, true); diff --git a/morphy/pubspec.yaml b/morphy/pubspec.yaml index dec0bb1..c079d23 100644 --- a/morphy/pubspec.yaml +++ b/morphy/pubspec.yaml @@ -1,14 +1,14 @@ name: morphy description: Provides a clean class definition with extra functionality including; copy with, json serializable, tostring, equals that supports inheritance and polymorphism -version: 1.0.0 +version: 1.0.0+1 homepage: https://github.com/atreeon/morphy environment: sdk: ">=3.1.3 <4.0.0" -dependency_overrides: - morphy_annotation: - path: ../morphy_annotation +#dependency_overrides: +# morphy_annotation: +# path: ../morphy_annotation dependencies: morphy_annotation: ^1.0.0