Skip to content

Instantly share code, notes, and snippets.

@IlyaHalsky
Last active June 29, 2018 12:28
Show Gist options
  • Save IlyaHalsky/cd0fbbfd98c85210f575a0093bb89c34 to your computer and use it in GitHub Desktop.
Save IlyaHalsky/cd0fbbfd98c85210f575a0093bb89c34 to your computer and use it in GitHub Desktop.
// 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