File tree Expand file tree Collapse file tree 3 files changed +4
-12
lines changed Expand file tree Collapse file tree 3 files changed +4
-12
lines changed Original file line number Diff line number Diff line change @@ -12,10 +12,6 @@ class Identifier {
12
12
13
13
String get key => '$type :$id ' ;
14
14
15
- // /// True if the [other] identifier references the same object.
16
- // bool hasSameReference(Identifier other) =>
17
- // type == other.type && id == other.id;
18
-
19
15
/// True if this identifier identifies the [resource] .
20
16
bool identifies (Resource resource) =>
21
17
type == resource.type && id == resource.id;
Original file line number Diff line number Diff line change 1
1
import 'package:json_api/src/document/identifier.dart' ;
2
2
import 'package:json_api/src/document/relationship.dart' ;
3
- import 'package:json_api/src/document/resource.dart' ;
4
- import 'package:json_api/src/document/resource_collection.dart' ;
5
3
6
4
class ToOne extends Relationship {
7
5
ToOne (this .identifier);
@@ -16,8 +14,4 @@ class ToOne extends Relationship {
16
14
@override
17
15
Iterator <Identifier > get iterator =>
18
16
identifier == null ? < Identifier > [].iterator : [identifier! ].iterator;
19
-
20
- /// Finds the referenced resource in the [collection] .
21
- Resource ? findIn (ResourceCollection collection) =>
22
- collection[identifier? .key];
23
17
}
Original file line number Diff line number Diff line change @@ -56,7 +56,7 @@ void main() {
56
56
expect (fetchedPost.attributes['title' ], 'Hello world' );
57
57
58
58
final fetchedAuthor =
59
- fetchedPost.one ('author' )! . findIn (response.included) ;
59
+ response.included[ fetchedPost.one ('author' )? .identifier ? .key] ;
60
60
expect (fetchedAuthor? .attributes['name' ], 'Alice' );
61
61
62
62
final fetchedComment =
@@ -120,7 +120,9 @@ void main() {
120
120
await client.fetchResource (post.type, post.id, query: [
121
121
Include (['author' ])
122
122
]).then ((r) {
123
- expect (r.resource.one ('author' )? .findIn (r.included)? .attributes['name' ],
123
+ expect (
124
+ r.included[r.resource.one ('author' )? .identifier? .key]
125
+ ? .attributes['name' ],
124
126
'Bob' );
125
127
});
126
128
});
You can’t perform that action at this time.
0 commit comments