Is NamedPartialFunction actually used anywhere?

26 views
Skip to first unread message

Rike-Benjamin Schuppner

unread,
Nov 23, 2015, 5:20:13 AM11/23/15
to Lift
Hi,

while looking through the code in order to fix a bug with the fixCSS implementation, I noticed the verbosity in the LiftRequestPF:

    val liftReq: LiftRules.LiftRequestPF = new LiftRules.LiftRequestPF {
      def functionName = "Default CSS Fixer"

      def isDefinedAt(r: Req): Boolean = {
        r.path.partPath == path
      }

      def apply(r: Req): Boolean = {
        r.path.partPath == path
      }
    }

Now, LiftRules.LiftRequestPF never declares a functionName (It is a plain typedef for PartialFuction.) so I guess it could simply be written as:

    val liftReq: LiftRules.LiftRequestPF = {
      case Req(p, _, _) if p == path => true
    }

But even more so: What if LiftRequestPF were a NamedPartialFunction (or NamedPF) which declares the functionName def. Would it actually be used anywhere? From quickly grepping the code, there seem to be a few definitions of NamedPartialFunctions but its main feature, the functionName seems nowhere to be used. Am I missing something here? Where could I take advantage of this.

Cheers
/rike

Reply all
Reply to author
Forward
0 new messages