MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / User

Class User

tests/fixtures/sample.kt:48–71  ·  view source on GitHub ↗

A user entity. */

Source from the content-addressed store, hash-verified

46
47/** A user entity. */
48class User(
49 id: String,
50 val name: String,
51 private val email: String,
52 internal val role: Role = Role.USER,
53) : Entity(id) {
54
55 var lastLogin: Instant? = null
56 private set
57
58 override fun validate(): Boolean {
59 return name.isNotBlank() && email.contains("@")
60 }
61
62 @Cacheable(ttl = 300)
63 suspend fun loadProfile(): Map<String, Any> {
64 println("Loading profile for $name")
65 return mapOf("name" to name, "role" to role)
66 }
67
68 companion object {
69 fun guest(): User = User("0", "Guest", "guest@example.com", Role.GUEST)
70 }
71}
72
73enum class Role {
74 ADMIN,

Callers 1

guestMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected