diff options
| author | ckonstanski <ckonstanski@pippiandcarlos.com> | 2018-02-06 21:42:54 -0700 |
|---|---|---|
| committer | ckonstanski <ckonstanski@pippiandcarlos.com> | 2018-02-06 21:42:54 -0700 |
| commit | 142166df54eda65925921799a4bb3e7f6cdaba48 (patch) | |
| tree | 5dc70e16bd6719079651925b5c5769211a3bf27e /service/generic-form.lisp | |
initial commit
Diffstat (limited to 'service/generic-form.lisp')
| -rw-r--r-- | service/generic-form.lisp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/service/generic-form.lisp b/service/generic-form.lisp new file mode 100644 index 0000000..96adc07 --- /dev/null +++ b/service/generic-form.lisp @@ -0,0 +1,45 @@ +;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*- +(declaim (optimize (speed 0) (safety 3) (debug 3))) + +(in-package #:music-dispensary) + +;; ========================================================================== ;; + +(defclass generic-form (rest-service) + ((name :initarg :name + :initform nil + :accessor name) + (http-method :initarg :http-method + :initform "POST" + :accessor http-method) + (action :initarg :action + :initform nil + :accessor action) + (form-fields :initarg :form-fields + :initform nil + :accessor form-fields)) + (:documentation "")) + +(defclass form-field (base-service) + ((name :initarg :name + :initform nil + :accessor name) + (label :initarg :label + :initform nil + :accessor label) + (field-type :initarg :field-type + :initform nil + :accessor field-type)) + (:documentation "")) + +(defmacro define-generic-form-constructor ((form-class name action) fields) + `(defmethod initialize-instance :after ((,form-class ,form-class) &key) + (setf (name ,form-class) ,name) + (setf (action ,form-class) ,action) + (setf (form-fields ,form-class) + (mapcar (lambda (form) + (make-instance 'form-field + :name (getf form :name) + :label (getf form :label) + :field-type (getf form :field-type))) + ,fields)))) |
