guard created values from being optimized out (bnc#895964)

You mention the caller sites as an alternative: https://github.com/yast/yast-ruby-bindings/blob/c538714930827e6adb7ee8f466201b586aa313ee/src/binary/Y2RubyReference.cc#L11

Yes. We need to explicitly oversee the lifetime of the ruby values.