Skip to content

Commit f12cee7

Browse files
committed
Fix missing methods for FetchableModel_Int
feature/add-unmanaged-protocol-for-types-that-prefer-a-unique-id-other-than-ObjectID
1 parent 036a4a0 commit f12cee7

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

Sources/Internal/ModelsWithIntId/FetchableModel_Int.swift

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,44 @@ package struct FetchableModel_IntId: Hashable, Sendable {
3939
self.string = string
4040
self.uuid = uuid
4141
}
42+
43+
@inlinable
44+
package static func defaulted(
45+
bool: Bool = true,
46+
date: Date = Date(),
47+
decimal: Decimal = 0,
48+
double: Double = 0,
49+
float: Float = 0,
50+
int: Int = 0,
51+
string: String = "",
52+
uuid: UUID = UUID()
53+
) -> Self {
54+
Self(
55+
bool: bool,
56+
date: date,
57+
decimal: decimal,
58+
double: double,
59+
float: float,
60+
int: int,
61+
string: string,
62+
uuid: uuid
63+
)
64+
}
65+
66+
@inlinable
67+
package static func seeded(_ seed: Int) -> Self {
68+
let _uuid = UUID(uniform: seed.description.first!)
69+
return Self(
70+
bool: seed.isMultiple(of: 2) ? true : false,
71+
date: Date(timeIntervalSinceReferenceDate: TimeInterval(seed)),
72+
decimal: Decimal(seed),
73+
double: Double(seed),
74+
float: Float(seed),
75+
int: seed,
76+
string: seed.description,
77+
uuid: _uuid
78+
)
79+
}
4280
}
4381

4482
extension FetchableModel_IntId: FetchableUnmanagedModel {

0 commit comments

Comments
 (0)