Open
Description
We're hitting an issue where we have to copy value from Flavor to Vm, but divide it by 2^20 prior saving. Something like:
persister.flavors.build(
...
:memory => flavor.memory_in_mb.megabytes # store in bytes
)
persister.hardwares.build(
...
:memory_mb => persister.flavors.find(flavor_ref).memory / 1.megabytes # convert to megabytes
)
Problem is that we currently have to use .find()
which may potentially result in ordering issues. Would it be possible to let .lazy_find()
accept a block where we could preprocess the value? Something like this would be fantastic:
persister.flavors.lazy_find(flavor_ref) { |flavor| flavor.memory / 1.megabyte }
/cc @agrare