(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-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`.
```clj
(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 protocols/IModel, protocols/IWithModel, and protocols/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 [[protocols/IModel]], [[protocols/IWithModel]], and [[protocols/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 an-instance)Return a copy of an-instance with its original value set to its current value, discarding the previous original
value. No-ops if an-instance is not a Toucan 2 instance.
Return a copy of `an-instance` with its `original` value set to its current value, discarding the previous original value. No-ops if `an-instance` is not a Toucan 2 instance.
(update-current an-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 an-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 `an-instance` is not an [[Instance]].
(update-original an-instance f & args)Applies f directly to the underlying original map of an-instance. No-ops if an-instance is not
an [[Instance]].
Applies `f` directly to the underlying `original` map of `an-instance`. No-ops if `an-instance` is not an [[Instance]].
(update-original-and-current an-instance f & args)Like (apply f instance args), but affects both the original map and current map of an-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 `an-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 builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |