Does the field know if it's the meta instance? ------------------------------------- David Pollak<feeder.of.the.be...@gmail.com> wrote:
On Fri, Feb 26, 2010 at 7:05 AM, Jeppe Nejsum Madsen <je...@ingolfs.dk>wrote: > Hi, > > I would expect the following code to print at most a single line: > > Vehicle.mappedFields.filter(_.dbIncludeInForm_?) foreach {f => > f match { > case Vehicle.customCategory => Log.info("Matched on field: "+ > f.name) > case _ => > } > } > > But what happens is that the following: > > 15:57:27.917 [tp-1441471922-0] INFO lift > - Matched on field: organizationalUnit > 15:57:27.918 [tp-1441471922-0] INFO lift > - Matched on field: price > 15:57:27.918 [tp-1441471922-0] INFO lift > - Matched on field: tax > 15:57:27.918 [tp-1441471922-0] INFO lift > - Matched on field: customCategory > 15:57:27.918 [tp-1441471922-0] INFO lift > - Matched on field: vehicleType > > I think what happens is that the equals method of MappedField compares > the value of the fields, which is 0 in the above cases. But this > doesn't make much sense when it is really the meta fields that are > being compared. > > Is it possible somehow to match on the fields, not the field values? > No... sorry. The equals method for fields allow: if (model.field == 3) ... rather than if (model.field.is == 3) ... Pattern matching uses the equals method. The comparison use case is likely to be more common than pattern matching against the Meta field. If you can figure out how to get the use case you're looking for without breaking the primary use case, I'm open to making them both work. > > /Jeppe > > -- > You received this message because you are subscribed to the Google Groups > "Lift" group. > To post to this group, send email to lift...@googlegroups.com. > To unsubscribe from this group, send email to > liftweb+unsubscr...@googlegroups.com<liftweb%2bunsubscr...@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/liftweb?hl=en. > > -- Lift, the simply functional web framework http://liftweb.net Beginning Scala http://www.apress.com/book/view/1430219890 Follow me: http://twitter.com/dpp Surf the harmonics -- You received this message because you are subscribed to the Google Groups "Lift" group. To post to this group, send email to lift...@googlegroups.com. To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/liftweb?hl=en. -- You received this message because you are subscribed to the Google Groups "Lift" group. To post to this group, send email to lift...@googlegroups.com. To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.