Mapper logic reuse - suggestions needed

I am noticing two patterns:

  1. I am creating a mapper for each unique combination of #combine inputs
  2. I having a lot of repeating code in my mappers across different relations when I combine associations.

Do you have any suggestion on how to not repeat code in different mappers OR even the same mapper?

For example I have this block in 3 different mappers OR repeating in the same mapper:

        guard(->(issue) { !issue[:feature].nil? }) do
          map_value(:feature) do
            unwrap :issue, [:comments]
            reject_keys [:issue]

            constructor_inject Feature

You can simply define re-usable mapping procs as constants and…re-use them :slightly_smiling_face:

No way to call a registered mapper from within another mapper?

If I have to go with the constant / proc solution where in the ROM framework should I be declaring them?

The ROM documentation has an example of what this looks like. In addition to using register_as, if you’d prefer to use a custom callable object you could also register it manually as part of the configuration step.