I am new to Ruby and this is a really basic question, when I searched for adding/appending values to OpenStruct, I couldn't find any resource.
I'm trying to wrap the response body with extra params and the code in place uses OpenStruct. Now I need to append some key/value later in the code before sending the final reponse.
OpenStruct.new(
body : api_response.body
check1? : true
)
I want to add check2? : false.
There are two ways to do it depending on what works best for the use case. One can either do a quick fix with something like this
OR an elegant way of doing it is to wrap the creation of your OpenStruct instance in a method that accepts the
check2?param. (This is what I did and it works great with named args!)There is a good blog for reference, which I got after considerable google search.