Skip to content

Instantly share code, notes, and snippets.

@FreekPaans
Last active March 11, 2016 07:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FreekPaans/895469b88314ddffe7aa to your computer and use it in GitHub Desktop.
Save FreekPaans/895469b88314ddffe7aa to your computer and use it in GitHub Desktop.
(ns layered-example.domain.cargo.cargo)
(defrecord Cargo [cargo-id size voyage-id])
(defn create-new-cargo [& {:keys [size voyage-id] :as cargo-data}]
{:pre [(integer? size)
(nil? voyage-id)]}
(map->Cargo cargo-data))
(defn book-onto-voyage [a-cargo & {:keys [voyage-id]}]
{:pre [(integer? voyage-id)
(nil? (:voyage-id a-cargo))]}
(assoc a-cargo :voyage-id voyage-id))
(defn set-cargo-id [a-cargo cargo-id]
{:pre [(not (:cargo-id a-cargo))]}
(assoc a-cargo :cargo-id cargo-id))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment