diff --git a/config.lisp b/config.lisp index a0df701..8cffeca 100644 --- a/config.lisp +++ b/config.lisp @@ -11,6 +11,8 @@ (in-package :scopes/config) +;;;; common base class for all config classes + (defclass common () ((children :accessor children :initarg children @@ -19,6 +21,8 @@ (defgeneric parent (cfg) (:method ((cfg common)) nil)) +;;;; config root (top-level) class with no parent + (defclass root (common) ((env-keys :reader env-keys :initform nil @@ -45,12 +49,15 @@ (setf (gethash sl data) env-val) (setf (gethash sl data) dotenv-val)))))) +;;;; config base class + (defclass base (common) ((parent :reader parent :initarg :parent))) (defmethod initialize-instance :after ((cfg base) &key parent &allow-other-keys) - (push cfg (children parent))) + (if parent + (push cfg (children parent)))) (defmethod (setf parent) ((cfg base) (parent common)) (push cfg (children parent))) diff --git a/core/core.lisp b/core/core.lisp index bb87461..fb2f2b1 100644 --- a/core/core.lisp +++ b/core/core.lisp @@ -5,11 +5,11 @@ (:local-nicknames (:config :scopes/config)) (:export #:config #:message - #:service #:name #:send)) + #:context #:name #:send)) (in-package :scopes/core) -(defclass config (config:root) +(defclass config (config:base) (services)) (defclass message () @@ -21,10 +21,12 @@ (timestamp) (data))) -(defclass service () +(defclass context () ((name :initarg :name :reader name))) (defgeneric send (rcvr msg) - (:method ((rcvr service) msg) + (:method ((rcvr context) msg) rcvr msg)) + +(defvar *context* nil) diff --git a/test/test-core.lisp b/test/test-core.lisp index 7724d2a..cbeab03 100644 --- a/test/test-core.lisp +++ b/test/test-core.lisp @@ -14,7 +14,7 @@ (defvar *config* nil) (defclass test-suite (t:test-suite) - ((receiver :initform (make-instance 'core:service :name :test-rcvr) + ((receiver :initform (make-instance 'core:context :name :test-rcvr) :reader receiver))) (defun run ()