(empty-map model)
Return an empty map that should be used as the basis for creating new instances of a model. You can provide a custom
implementation if you want to use something other than the default toucan2.magic-map
implementation.
Return an empty map that should be used as the basis for creating new instances of a model. You can provide a custom implementation if you want to use something other than the default [[toucan2.magic-map]] implementation.
(instance model)
(instance model m)
(instance model k v & more)
(instance-of? model x)
True if x
is a Toucan2 instance, and its [[protocols/model]] isa?
model
.
(instance-of? ::bird (instance ::toucan {})) ; -> true (instance-of? ::toucan (instance ::bird {})) ; -> false
True if `x` is a Toucan2 instance, and its [[protocols/model]] `isa?` `model`. (instance-of? ::bird (instance ::toucan {})) ; -> true (instance-of? ::toucan (instance ::bird {})) ; -> false
(instance? x)
True if x
is a Toucan2 instance, i.e. a toucan2.instance.Instance
or some other class that satisfies the correct
interfaces.
Toucan instances need to implement [[IModel]], [[IWithModel]], and [[IRecordChanges]].
True if `x` is a Toucan2 instance, i.e. a `toucan2.instance.Instance` or some other class that satisfies the correct interfaces. Toucan instances need to implement [[IModel]], [[IWithModel]], and [[IRecordChanges]].
(key-transform-fn model)
Function to use to magically transform map keywords when building a new instance of model
.
Function to use to magically transform map keywords when building a new instance of `model`.
(reset-original instance)
Return a copy of instance
with its original
value set to its current value, discarding the previous original
value. No-ops if instance
is not a Toucan 2 instance.
Return a copy of `instance` with its `original` value set to its current value, discarding the previous original value. No-ops if `instance` is not a Toucan 2 instance.
(update-current instance f & args)
Applies f
directly to the underlying current
map of an instance
; useful if you need to operate on it directly.
Acts like regular (apply f instance args)
if instance
is not an Instance
.
Applies `f` directly to the underlying `current` map of an `instance`; useful if you need to operate on it directly. Acts like regular `(apply f instance args)` if `instance` is not an `Instance`.
(update-original instance f & args)
Applies f
directly to the underlying original
map of an instance
. No-ops if instance
is not an Instance
.
Applies `f` directly to the underlying `original` map of an `instance`. No-ops if `instance` is not an `Instance`.
(update-original-and-current instance f & args)
Like (apply f instance args)
, but affects both the original
map and current
map of instance
rather than just
the current map. Acts like regular (apply f instance args)
if instance
is not an Instance
.
f
is applied directly to the underlying original
and current
maps of instance
itself. f
is only applied
once if original
and current
are currently the same object (i.e., the new original
and current
will also be
the same object). If current
and original
are not the same object, f
is applied twice.
Like `(apply f instance args)`, but affects both the `original` map and `current` map of `instance` rather than just the current map. Acts like regular `(apply f instance args)` if `instance` is not an `Instance`. `f` is applied directly to the underlying `original` and `current` maps of `instance` itself. `f` is only applied once if `original` and `current` are currently the same object (i.e., the new `original` and `current` will also be the same object). If `current` and `original` are not the same object, `f` is applied twice.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close