From d9558e742ac630bfa86c87f46326f8ba16f31300 Mon Sep 17 00:00:00 2001 From: Mateusz Kubuszok Date: Thu, 14 Sep 2023 21:24:31 +0200 Subject: [PATCH] Add inherited accessors to the docs --- .../transformers/customizing-transformers.rst | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/docs/source/transformers/customizing-transformers.rst b/docs/source/transformers/customizing-transformers.rst index 0bed34cb4..691ced7a6 100644 --- a/docs/source/transformers/customizing-transformers.rst +++ b/docs/source/transformers/customizing-transformers.rst @@ -102,6 +102,32 @@ and have no parameter list are considered. // FooV2(1, "m") +Using inherited accessors +------------------------- + +By default, Chimney will only consider ``val`` and ``lazy val`` (and ``def`` if you enable method accessors) defined +directly within the source type, because it might be surprising to lookup all possible method inherited by supertypes or +mixins. + +You can ask Chimney to consider inherited ``val`` and ``lazy val`` (and ``def`` if methods accessors are enabled) with +``.enableInheritedAccessors``. Note that only methods that are public and have no parameter list are considered. + +.. code-block:: scala + + trait SourceParent { + val value: String = "value" + } + class Source extends SourceParent + + case class Target(value: String) + + (new Source) + .into[Target] + .enableInheritedAccessors + .transform + // Target("value") + + Transforming coproducts -----------------------