Liking cljdoc? Tell your friends :D

toucan2.instance


empty-mapclj

(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.
sourceraw docstring

instanceclj

(instance model)
(instance model m)
(instance model k v & more)
source

instance-of?clj

(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
```
sourceraw docstring

instance?clj

(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]].
sourceraw docstring

key-transform-fnclj

(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`.
sourceraw docstring

reset-originalclj

(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.
sourceraw docstring

update-currentclj

(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]].
sourceraw docstring

update-originalclj

(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]].
sourceraw docstring

update-original-and-currentclj

(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.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close