Skip to content

Commit

Permalink
Merge pull request #331 from nafg/move-aslookup-up-to-lookup--so-it-c…
Browse files Browse the repository at this point in the history
…an-be-used-from

Move asLookup up to Lookup, so it can be used from EntityKey as well.
  • Loading branch information
nafg authored Dec 22, 2023
2 parents e3d9e29 + 31b55e2 commit e0a4afd
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ sealed trait Lookup[K, +A] extends EntityRef[K, A] {
override def transform[B](f: A => B): Lookup[K, B]
override def updated[B](value: B): Lookup[K, B]
override def widen[B >: A]: Lookup[K, B]

def asLookup: Lookup[K, A] = this

def foldLookup[X](key: EntityKey[K, A] => X, ent: KeyedEntity[K, A] => X): X =
this match {
case ek: EntityKey[K, A] => key(ek)
Expand Down Expand Up @@ -76,7 +79,6 @@ sealed trait KeyedEntity[K, +A] ext
override def updated[B](value: B): ModifiedEntity[K, B] = ModifiedEntity(key, value)

def toSaved: SavedEntity[K, A] = SavedEntity(key, value)
def asLookup: Lookup[K, A] = this
override def toEntityKey: EntityKey[K, A] = EntityKey(key)
}
object KeyedEntity {
Expand Down

0 comments on commit e0a4afd

Please sign in to comment.