accept explicit parameters in quote-identifiers

This commit is contained in:
Justin Kramer 2013-08-07 10:30:15 -04:00
parent 35fbbabffa
commit cff7abad1f
2 changed files with 11 additions and 5 deletions

View file

@ -11,6 +11,7 @@
(defalias param types/param)
(defalias format format/format)
(defalias format-predicate format/format-predicate)
(defalias quote-identifier format/quote-identifier)
(defn qualify
"Takes one or more keyword or string qualifers and name. Returns

View file

@ -36,11 +36,16 @@
(def ^:dynamic *quote-identifier-fn* nil)
(defn quote-identifier [x]
(if-not *quote-identifier-fn*
x
(let [parts (string/split (name x) #"\.")]
(string/join "." (map #(*quote-identifier-fn* %) parts)))))
(defn quote-identifier [x & {:keys [style split] :or {split true}}]
(let [qf (if style
(quote-fns style)
*quote-identifier-fn*)]
(if-not qf
x
(if-not split
(qf (name x))
(let [parts (string/split (name x) #"\.")]
(string/join "." (map qf parts)))))))
(def infix-fns
#{"+" "-" "*" "/" "%" "mod" "|" "&" "^"