This is not global issue, maybe a kind of case report.
2.2.0 contains big refactoring (#65) and it makes sense. However compatibility code made an issue on my code.
I have Parts module,
module Parts
class Foo; end
end
And with 2.1.1, it works fine.
$ bundle exec irb
2.7.2 :001 > require_relative 'parts/foo'
=> true
2.7.2 :002 > require 'net/http/post/multipart'
=> true
2.7.2 :003 > Parts::Foo.class
=> Class
2.7.2 :004 > Parts.constants
=> [:Foo, :Part, :EpiloguePart, :FilePart, :ParamPart]
However, with 2.2.0, it have loading order issue.
When load modules on following order, it works.
- Multipart gem
- my
Parts module
2.7.2 :001 > require 'net/http/post/multipart'
=> true
2.7.2 :003 > Multipart::Post::Parts.class
=> Module
2.7.2 :006 > require_relative 'parts/foo'
=> true
2.7.2 :007 > Parts.class
=> Module
2.7.2 :011 > Parts.constants
=> [:Foo]
But when following order, it does not work.
- my
Parts module
- Multipart gem
2.7.2 :001 > require_relative 'parts/foo'
=> true
2.7.2 :002 > require 'net/http/post/multipart'
/usr/local/rvm/gems/ruby-2.7.2/gems/multipart-post-2.2.3/lib/multipart/post/parts.rb:151: warning: already initialized constant Parts
/workspaces/sandbox-ruby/simple/parts/foo.rb:3: warning: previous definition of Parts was here
=> true
2.7.2 :003 > Parts::Foo
Traceback (most recent call last):
21: from /usr/local/rvm/gems/ruby-2.7.2/bin/ruby_executable_hooks:22:in `<main>'
20: from /usr/local/rvm/gems/ruby-2.7.2/bin/ruby_executable_hooks:22:in `eval'
19: from /usr/local/rvm/gems/ruby-2.7.2/bin/irb:23:in `<main>'
18: from /usr/local/rvm/gems/ruby-2.7.2/bin/irb:23:in `load'
17: from /usr/local/rvm/gems/ruby-2.7.2/gems/irb-1.4.1/exe/irb:11:in `<top (required)>'
(irb):3:in `<main>': uninitialized constant Multipart::Post::Parts::Foo (NameError)
I guess it led by here
|
Parts = Multipart::Post::Parts |
, and it is for compatibility.
If that part of code change, it would be breaking change. so, I'm not sure how it should be fixed.
Do you have any ideas? Like applying a monkey patch?
This is not global issue, maybe a kind of case report.
2.2.0 contains big refactoring (#65) and it makes sense. However compatibility code made an issue on my code.
I have
Partsmodule,And with 2.1.1, it works fine.
However, with 2.2.0, it have loading order issue.
When load modules on following order, it works.
PartsmoduleBut when following order, it does not work.
PartsmoduleI guess it led by here
multipart-post/lib/multipart/post/parts.rb
Line 151 in 31500a7
If that part of code change, it would be breaking change. so, I'm not sure how it should be fixed.
Do you have any ideas? Like applying a monkey patch?