Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8e2341c
commit 6b2d8b0
Showing
4 changed files
with
26 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,17 @@ | ||
(ns clj-record.callbacks.built-ins) | ||
|
||
|
||
(defn transform-value [attribute func] | ||
(defn transform-value | ||
"Given an attribute name and a function, creates a callback function that | ||
uses the given function to transform the named attribute in a record. | ||
Assuming clj-record.callbacks.built-ins has been aliased to cb, | ||
you might do this in an init-model form: | ||
... | ||
(:callbacks | ||
(:before-save (cb/transform-value :save-count inc))) | ||
..." | ||
[attribute func] | ||
(fn [record] | ||
(assoc record attribute (func (record attribute))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters