Skip to content
This repository has been archived by the owner on Jul 1, 2020. It is now read-only.

Feature idea: a special key to tell Hashformer to copy any source key not in the transformation #1

Open
mike-bourgeous opened this issue Jul 23, 2016 · 1 comment

Comments

@mike-bourgeous
Copy link
Contributor

mike-bourgeous commented Jul 23, 2016

Basic concept:

data = { a: 1, b: 2, c: 3, d: 4 }
xform = {
  __copy_keys: true,
  b: HF[:b].__as{|b| 1.0 / b }
}
HF.transform(data, xform)

Should result in

{ a: 1, b: 0.5, c: 3, d: 4 }

If feeling really adventurous, specify which keys to copy:

data = { a: 1, b: 2, c: 3, d: 4 }
xform = {
  __copy_keys: [:c, :d],
  b: HF[:b].__as{|b| 1.0 / b }
}
HF.transform(data, xform)

Should result in

{ b: 0.5, c: 3, d: 4 }
@ezmiller
Copy link

I also wonder if this would be a good feature. Perhaps, it could also be an option on the transform method?

My use cases is that I'd like to modularize a series of transformations that build on each other. In each stage, I'd like to pass through the values that I've not modified/added.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants