Factories & Building
(ns fab.tutorial
(:require [fabrikk.core.alpha :as fab]))
(def user
(fab/->factory
::user
{:template {:name "John Smith"
:email "john@example.org"
:role "admin"}}) Last updated
(ns fab.tutorial
(:require [fabrikk.core.alpha :as fab]))
(def user
(fab/->factory
::user
{:template {:name "John Smith"
:email "john@example.org"
:role "admin"}}) Last updated
(fab/build user)
;; => {:name "John Smith", :email "john@example.org", :role "admin"}
(fab/build user)
;; => {:name "John Smith", :email "john@example.org", :role "admin"};; we use 'with' to change the name:
(fab/build user {:with {:name "John Murphy"}})
;; => {:name "John Murphy", :email "john@example.org", :role "admin"}
;; or add an arbitrary key to the entity:
(fab/build user {:with {:favourite-food "chips"}})
;; => {:name "John Smith", :email "john@example.org", :role "admin",
;; :favourite-food "chips"}