diff options
author | colin <colin@cicadas.surf> | 2023-03-05 16:36:44 -0800 |
---|---|---|
committer | colin <colin@cicadas.surf> | 2023-03-05 16:36:44 -0800 |
commit | f7abccc38ceda7024ca375d34ed88f4fb561ef02 (patch) | |
tree | 432d6673e9e8d53b5fbc43e25a684b654f6dea1d /src/names.lisp | |
parent | 89d0d687992b41f7f0f9b0d3da19d9d587f06010 (diff) |
Reorganized codebase
Diffstat (limited to 'src/names.lisp')
-rw-r--r-- | src/names.lisp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/names.lisp b/src/names.lisp new file mode 100644 index 0000000..8cc64af --- /dev/null +++ b/src/names.lisp @@ -0,0 +1,25 @@ +;;;; names.lisp -- a protocol for getting the names of things, and +;;;; generally referring to objects with strings. + +(in-package :dnd) + +(defgeneric unique-name (object) + (:documentation "Returns a unique name for an object, or NIL if it does not have one.") + (:method ((ob t)) nil)) + +(defmethod unique-name ((campaign campaign)) + (campaign-title campaign)) + +(defmethod unique-name ((hero hero)) + (hero-name hero)) + +(defgeneric urlpath (object) + (:documentation "Return the path to the object given a particular") + (:method ((object has-uid)) + "If the object has a unique human readable name, urlify that name and +incorporate it into the urlpath. Otherwise use the object's uid. + +Returns /inflection/class/identifier." + (format nil "/~a/~a" + (urlify (class-name (class-of object))) + (urlify (or (unique-name object) (uid object)))))) |