mirror of
https://github.com/safishamsi/graphify.git
synced 2026-07-13 10:57:13 +00:00
67b4525f32
The Scala field handler matched only `val_definition`, so a mutable field (`var b: Repo`), which parses as `var_definition`, had its type reference silently dropped from the graph. val and var nodes are structurally identical (both expose a `type` field), so the existing type-collection logic works unchanged. Widen the guard to accept var_definition. Adds a var field to the Scala fixture and a regression test.
30 lines
660 B
Scala
30 lines
660 B
Scala
import scala.collection.mutable.ListBuffer
|
|
|
|
case class Config(baseUrl: String, timeout: Int)
|
|
|
|
trait Loggable
|
|
abstract class BaseClient
|
|
|
|
class HttpClient(config: Config) extends BaseClient with Loggable {
|
|
val source: Config = config
|
|
var fallback: BaseClient = null
|
|
|
|
def get(path: String): String = {
|
|
buildRequest("GET", path)
|
|
}
|
|
|
|
def post(path: String, body: String): String = {
|
|
buildRequest("POST", path)
|
|
}
|
|
|
|
private def buildRequest(method: String, path: String): String = {
|
|
s"$method ${config.baseUrl}$path"
|
|
}
|
|
}
|
|
|
|
object HttpClientFactory {
|
|
def create(baseUrl: String): HttpClient = {
|
|
new HttpClient(Config(baseUrl, 30))
|
|
}
|
|
}
|