Last active
June 29, 2018 12:28
-
-
Save IlyaHalsky/cd0fbbfd98c85210f575a0093bb89c34 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Paw: List[Access[P]], where P is Orig, used in filters | |
def resetFilters(defaultModelRegistry: DefaultModelRegistry, accesses: List[Access[_ <: Product]]): Context ⇒ Context = { | |
val lambdas = | |
for { | |
access ← accesses | |
} yield { | |
val initValue = access.initialValue | |
val srcId = ToPrimaryKey(initValue) | |
val accessCl = initValue.getClass.getName | |
val default = defaultModelRegistry.get(accessCl).create(srcId) | |
access.updatingLens.get.set(default) | |
} | |
if (lambdas.nonEmpty) | |
lambdas.reduce((a,b) ⇒ a andThen b) | |
else | |
identity | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment