Skip to content

Drop OpenStruct use from FakeApplicationSettings

Matthias Käppler requested to merge mk-fake-app-settings-rework into master

What does this MR do?

OpenStruct has been pointed out as problematic to use. Ruby 3 added a good Caveats section to the OpenStruct rdoc explaining why its use is often not a good idea: https://docs.ruby-lang.org/en/3.0.0/OpenStruct.html#class-OpenStruct-label-Caveats

The problem this MR fixes is that the current implementation of FakeApplicationSettings, which is derived from OpenStruct, will actually break under Ruby 3, due to a change that materializes attributes passed through the constructor eagerly rather than lazily, which breaks inheritance contracts (such as the inclusion of module methods that are meant to override ostruct members.)

Context: #336754 (comment 646177087)

Therefore, this patch drops the use of OpenStruct entirely in this class in favor of some hand-rolled (but simple) meta-programming that mimics OStruct behavior from 2.7 where relevant.

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Edited by Matthias Käppler

Merge request reports

Loading