Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IB::Contract in ib-extensions has different superclass (Object) than ib-api #7

Open
pelly opened this issue Nov 8, 2021 · 4 comments

Comments

@pelly
Copy link

pelly commented Nov 8, 2021

IB::Contract defined in
https://github.com/ib-ruby/ib-extensions/blob/master/lib/ib/models/contract.rb
has Object as it's superclass (since it doesn't extend any class explicitly)

But IB::Contract defined in
https://github.com/ib-ruby/ib-api/blob/master/lib/models/ib/contract.rb
has IB::Model as its superclass.

As a result, requiring both of these files will cause a mismatched superclass exception:

/home/user/.rvm/rubies/ruby-3.0.0/lib/ruby/gems/3.0.0/gems/ib-api-972.5/lib/models/ib/contract.rb:14:in `<module:IB>': superclass mismatch for class Contract (TypeError)
	from /home/user/.rvm/rubies/ruby-3.0.0/lib/ruby/gems/3.0.0/gems/ib-api-972.5/lib/models/ib/contract.rb:6:in `<top (required)>'
	from <internal:/home/user/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:96:in `require'
	from <internal:/home/user/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:96:in `require'
@topofocus
Copy link
Member

topofocus commented Nov 10, 2021

Hi,
the contract class in ib-extensions reopens IB::Contract defined in ib-api.

As ib-extensions depends on ib-api, IB::Contract should always been initialized before the model-file in ib-extensions is parsed.

How do you initialize ib-extensions?

@pelly
Copy link
Author

pelly commented Nov 10, 2021 via email

@topofocus
Copy link
Member

Thanks for bringing this to my attention.
You are right, its considered as bad practice to reopen classes across ruby-gems.

A proper solution would to use mixins and include/prepend them later.

That would translate in a change of the design of ib-extensions.

Your opinion?

@pelly
Copy link
Author

pelly commented Nov 13, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants