forked from lichess-org/lila
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Profile.scala
31 lines (21 loc) · 703 Bytes
/
Profile.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package lila.user
import scala._
case class Profile(
country: Option[String] = None,
location: Option[String] = None,
bio: Option[String] = None,
firstName: Option[String] = None,
lastName: Option[String] = None) {
def nonEmptyRealName = List(ne(firstName), ne(lastName)).flatten match {
case Nil => none
case names => (names mkString " ").some
}
def countryInfo = country flatMap Countries.info
def nonEmptyLocation = ne(location)
def nonEmptyBio = ne(bio)
private def ne(str: Option[String]) = str filter (_.nonEmpty)
}
object Profile {
val default = Profile()
private[user] val profileBSONHandler = reactivemongo.bson.Macros.handler[Profile]
}