-
Notifications
You must be signed in to change notification settings - Fork 606
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
Clean up define method #3617
Clean up define method #3617
Conversation
…define_method which is needed by Method and UnboundMethod
… delegate responsibility further to executables
…lity of Method,UnboundMethod #for_define_method, add 3rd arg callabale_proc to Method,UnboundMethod #for_define_method
…nvironment::AsMethod
… @ruby_method is set
Regarding to d59ca90 My reasoning behind this was this code part in the previous impl: We used the block scope after duping the proc but also we duped the block first. |
@tak1n this is a great first step, thanks for working on it. We'll continue to evolve some of these APIs to be even more simple. If you feel confident with this now, go ahead and merge, please! 👍 |
… old impl to ensure the same behavior
First I tried to ship most of the logic towards executables and use
Method#for_define_method
andUnbindMethod#for_define_method
as thin wrapper aroundExecutable#for_define_method
.The result can be seen here: 7cd4315
When the need to support Proc again came up it was clear that shipping most of the stuff into executables was not quite doable, or at least I was not able to do it properly.
Therefore I moved it up into
Method
andUnboundMethod
where again we have nested conditionals (but at least no more nested conditionals in a big fat case statement)As for
BlockEnvironment::AsMethod#scope
I'm not sure if this should return nil or the scope of@block_env
. In the previous implementationdefine_method
for aBlockEnvironment::AsMethod
executable used nil as scope. Also when changing it to@block_env.scope
all ci specs are still passing so probably this means there are missing specs for that.