mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-06 13:35:50 +01:00
Replace implicit conversion with implicit class.
This commit is contained in:
@@ -8,7 +8,7 @@ import scala.slick.driver.H2Driver.simple._
|
||||
*/
|
||||
object Implicits {
|
||||
|
||||
implicit def extendsSeq[A](seq: Seq[A]) = new {
|
||||
implicit class RichSeq[A](seq: Seq[A]) {
|
||||
|
||||
def splitWith(condition: (A, A) => Boolean): Seq[Seq[A]] = split(seq)(condition)
|
||||
|
||||
@@ -26,7 +26,7 @@ object Implicits {
|
||||
}
|
||||
|
||||
// TODO Should this implicit conversion move to model.Functions?
|
||||
implicit def extendsColumn(c1: Column[Boolean]) = new {
|
||||
implicit class RichColumn(c1: Column[Boolean]){
|
||||
def &&(c2: => Column[Boolean], guard: => Boolean): Column[Boolean] = if(guard) c1 && c2 else c1
|
||||
}
|
||||
|
||||
|
||||
@@ -75,6 +75,7 @@ object helpers {
|
||||
// convert commit id to link
|
||||
.replaceAll("(^|\\W)([a-f0-9]{40})(\\W|$)", "$1<a href=\"%s/%s/%s/commit/$2\">$2</a>$3").format(context.path, repository.owner, repository.name))
|
||||
|
||||
|
||||
/**
|
||||
* Returns <img> which displays the avatar icon.
|
||||
* Looks up Gravatar if avatar icon has not been configured in user settings.
|
||||
@@ -101,7 +102,7 @@ object helpers {
|
||||
/**
|
||||
* Implicit conversion to add mkHtml() to Seq[Html].
|
||||
*/
|
||||
implicit def extendsHtmlSeq(seq: Seq[Html]) = new {
|
||||
implicit class RichHtmlSeq(seq: Seq[Html]) {
|
||||
def mkHtml(separator: String) = Html(seq.mkString(separator))
|
||||
def mkHtml(separator: scala.xml.Elem) = Html(seq.mkString(separator.toString))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user