package utils

import play.api.mvc._

/**
 * A predicated action is one where a condition must be satisfied in order to proceed with the request. If the
 * condition is not satisfied then a supplied status result is yielded.
 */
class PredicatedActionBuilder {
  def apply[A](p: => Boolean, failed: Result)(action: Action[A]): Action[A] = new Action[A] {
    def apply(request: Request[A]): Result = {
      if (p) action(request) else failed
    }

    lazy val parser = action.parser
  }
}

object PredicatedAction extends PredicatedActionBuilder
package utils

import play.api.mvc._

/**
 * A predicated action is one where a condition must be satisfied in order to proceed with the request. If the
 * condition is not satisfied then a supplied status result is yielded.
 */
class PredicatedActionBuilder {
  def apply[A](p: Boolean, failed: Result)(action: Action[A]): Action[A] = new Action[A] {
    def apply(request: Request[A]): Result = {
      if (p) action(request) else failed
    }

    lazy val parser = action.parser
  }
}

object PredicatedAction extends PredicatedActionBuilder
--- 
+++ 
@@ -7,7 +7,7 @@
  * condition is not satisfied then a supplied status result is yielded.
  */
 class PredicatedActionBuilder {
-  def apply[A](p: Boolean, failed: Result)(action: Action[A]): Action[A] = new Action[A] {
+  def apply[A](p: => Boolean, failed: Result)(action: Action[A]): Action[A] = new Action[A] {
     def apply(request: Request[A]): Result = {
       if (p) action(request) else failed
     }
Revert "Doesn't require a function declaration for the predicate"

This reverts commit a4dabeee7c7d08fe20b5f895b7adc2312ffb1367.
