Skip to content

Commit 16b37f3

Browse files
committed
Remove ToOne.findIn
1 parent 49b766e commit 16b37f3

File tree

3 files changed

+4
-12
lines changed

3 files changed

+4
-12
lines changed

lib/src/document/identifier.dart

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ class Identifier {
1212

1313
String get key => '$type:$id';
1414

15-
// /// True if the [other] identifier references the same object.
16-
// bool hasSameReference(Identifier other) =>
17-
// type == other.type && id == other.id;
18-
1915
/// True if this identifier identifies the [resource].
2016
bool identifies(Resource resource) =>
2117
type == resource.type && id == resource.id;

lib/src/document/one.dart

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import 'package:json_api/src/document/identifier.dart';
22
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';
53

64
class ToOne extends Relationship {
75
ToOne(this.identifier);
@@ -16,8 +14,4 @@ class ToOne extends Relationship {
1614
@override
1715
Iterator<Identifier> get iterator =>
1816
identifier == null ? <Identifier>[].iterator : [identifier!].iterator;
19-
20-
/// Finds the referenced resource in the [collection].
21-
Resource? findIn(ResourceCollection collection) =>
22-
collection[identifier?.key];
2317
}

test/contract/crud_test.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ void main() {
5656
expect(fetchedPost.attributes['title'], 'Hello world');
5757

5858
final fetchedAuthor =
59-
fetchedPost.one('author')!.findIn(response.included);
59+
response.included[fetchedPost.one('author')?.identifier?.key];
6060
expect(fetchedAuthor?.attributes['name'], 'Alice');
6161

6262
final fetchedComment =
@@ -120,7 +120,9 @@ void main() {
120120
await client.fetchResource(post.type, post.id, query: [
121121
Include(['author'])
122122
]).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'],
124126
'Bob');
125127
});
126128
});

0 commit comments

Comments
 (0)