Closed Earlopain closed 1 month ago
Furthermore, OpenStruct usage is generally discouraged, due to invalidating the global method cache in Ruby.
From RuboCop documentation:
Instantiation of an
OpenStruct
invalidates Ruby global method cache as it causes dynamic method definition during program runtime.
Ruby 3.3.5 now warns about this.
irb(main):001> require "mailgun" /home/user/Documents/mailgun-ruby/lib/mailgun.rb:8: warning: ostruct was loaded from the standard library, but will no longer be part of the default gems starting from Ruby 3.5.0. You can add ostruct to your Gemfile or gemspec to silence this warning.
Ruby 3.4 will issue a warning for this, and Ruby 3.5 will raise. Also see https://bugs.ruby-lang.org/issues/20309, https://github.com/ruby/ruby/pull/10428
There is a single place here that will need adjusting: https://github.com/mailgun/mailgun-ruby/blob/1a2d2dcf253c2265267d261595416daa879a6342/lib/mailgun/response.rb#L15-L19
The other places are test only and can be fixed simply by adding it to the Gemfile (or alternativly just return a hash from
response_generator
and use thefrom_hash
method, seems like that should work). I suggest replacing the one usage with the following (untested, should be fine):