OpenStruct
objects are useful when you need something to fit a certain method call interface (i.e. send in a duck-typed object responding to #name
and #value
), or when you want to encapsulate the implementation details, but also want to avoid over-engineering the solution. They also make an awesome stub object, and I often use them in place of framework stubs when I don’t need the overhead of a stub/mock.