Closed jjatinggoyal closed 2 months ago
We may want to just get rid of our OpenStruct since we don't use it much.
It's moving out of Ruby core to a bundled gem in 3.5: https://bugs.ruby-lang.org/issues/20309
Could possibly replace it with Data
or something Rails provides.
Just read up on Data
class, look like it requires you to declare the class attributes beforehand, which doesn't fit our use case here one-to-one.
As for rails, maybe ActiveSupport::HashWithIndifferentAccess
could be used, but the access pattern is different than ostruct. Do you have anything specific in mind?
Might not be worth messing with yet.
We should also add ostruct
as a dependency in the gemspec as it will be removed from Ruby in 3.5.
Cool, let me add ostruct
as a dependency. Won't mention a min version, hope that is fine.
@excid3 does this PR look good to you? Can we merge it?
I figured out a way to remove OpenStruct and use a feature built-in to Rails instead.
Pull Request
Summary: Running into
Error: NameError: uninitialized constant Pay::Webhook::OpenStruct
error whenPay::Webhooks::ProcessJob
is running forpaddle_billing
Description: I'm integrating paddle with pay gem into my application, and have configured multiple webhooks for syncing subscriptions.
However, I'm running into the following error in
Pay::Webhooks::ProcessJob
:To fix the issue, I have explicitly added
require "ostruct"
to thePay::Webhook
model, and added a test case forpaddle_billing
for the same model.Additionally, added the
require "ostruct"
line toPay::Braintree::Subscription
model (the only other place where OpenStruct is used) as well proactively.Testing: Tested the fixes in this PR on my staging server, the webhook job passes now.
Screenshots (if applicable):
The first (failed) run in above screenshot is with pay-8.0.0, while the second successful run is with the fixes in this PR.
Additional Notes: My setup is: