Debian Codegraph @

src/camel_snake_kebab/internals/alter_name.cljc

raw
1 (ns ^:no-doc camel-snake-kebab.internals.alter-name
2 #?(:clj (:import (clojure.lang Keyword Symbol))))
3
4 (defprotocol AlterName
5 (alter-name [this f] "Alters the name of this with f."))
6
7 (extend-protocol AlterName
8 #?(:clj String
9 :cljs string)
10 (alter-name [this f]
11 (-> this f))
12
13 Keyword
14 (alter-name [this f]
15 (if (namespace this)
16 (throw (ex-info "Namespaced keywords are not supported" {:input this}))
17 (-> this name f keyword)))
18
19 Symbol
20 (alter-name [this f]
21 (if (namespace this)
22 (throw (ex-info "Namespaced symbols are not supported" {:input this}))
23 (-> this name f symbol))))