Skip to content

Commit

Permalink
Merge pull request #56 from plexus/model-check-record
Browse files Browse the repository at this point in the history
Change model? to check for records
  • Loading branch information
camsaul authored Mar 25, 2019
2 parents a880fbe + bbc8bf6 commit e028b22
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/toucan/models.clj
Original file line number Diff line number Diff line change
Expand Up @@ -378,9 +378,11 @@
([model k v & more]
(apply (resolve 'toucan.db/select-one) model k v more)))

(def ^:const ^{:arglists '([model])} ^Boolean model?
(defn model?
"Is model a valid toucan model?"
::model)
[model]
(and (record? model)
(::model model)))

;; We use the same record type (e.g., `DatabaseInstance`) for both the "model" (e.g., `Database`) and objects fetched
;; from the DB ("instances"). Model definitions have the key `::model` assoced so we can differentiate.
Expand Down

0 comments on commit e028b22

Please sign in to comment.