Add method to binder to override alias of current mapping, by passing the current mapping to the influencer closure

Description

If using a mapDirectory influence closure, you must do the following to override the current mapping's alias:

binder.getCurrentMapping().setAlias( 'foo' );

Give the binder a direct passthrough method to do this for consistency and brevity.

binder.setAlias( 'foo' );

Activity

Show:
Luis Majano
September 21, 2016, 8:04 PM

but in order to do that, you must be already in a mapping sequence. If not, there is no context. Is this what you mean/?

Brad Wood
September 21, 2016, 9:30 PM

Yes, that's point-- this closure is called during execution of a mapDirectory() command, which means there will always be a current mapping context.

Looking at this ticket again-- i think the fix is even simpler. We just need to pass the current mapping to the closure as an argument! Then there will be no need to try and get it from the binder.

In fact, the hint for the "influence" argument says this:

The influence closure or UDF that will receive the currently working mapping so you can influence it during the iterations

That's not even a true statement since the influence closure only receives the binder and the targetpath right now, but I think it shows that this is how the closure was originally intended to be implemented.

Brad Wood
September 21, 2016, 9:33 PM
Edited

Basically, edit this code in the binder's mapDirectory method:

with this...

Now the influence closure will receive a reference to the current mapping.

Fixed

Assignee

Luis Majano

Reporter

Brad Wood

Components

Fix versions

Priority

Major
Configure