Passing values to mapper without using "map_with"

In the documentation (ROM - Mappers) you can use the >> operator to pass data to a custom mapper.

If I have defined a mapper class inheriting from ROM::Transformer, what would the syntax be to pass data to it via >> (or other method)?

I’m aware of Relation#map_with but I need to pass a cached value into the mapper. How can I do this?

Many thanks!!

Could you show an example of what you’re trying to achieve? I’m not sure what you’re after exactly.

Given that I have a mapper class defined MyMapper:

result = my_relation.by_pk(id)
…some other code
send result through mapper here without hitting the db…
mapped_results = results >> MyMapper.new ??

Is this possible and what is the correct syntax?

Ohh, it’s just a function. So my_mapper.call(results) :slightly_smiling_face:

Thank you! That seems obvious now given " A mapper can be any object which responds to #call, which accepts a relation and return an array with results back".
:slight_smile: Sorry to take your time for this.

No worries :slightly_smiling_face: I hope it does the trick for you.