-
Notifications
You must be signed in to change notification settings - Fork 9
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
Send RAW method params to handler #25
base: master
Are you sure you want to change the base?
Conversation
@WiRight thanks for the PR. This technically works but removes an elegant feature from this library, specifically the 'explosion' of the positional parameters. eg now the handler will be forced to be defined as taking one parameter, whether it be array or object:
vs
The later is clearer to understand and I feel more in line w/ the 'ruby-esque' way of making code simple and intuitive. Ruby also supports 'named' params which can be 'exploded' using the 'double splat' operator. See this article for reference. What I would suggest here is to detect the type of the 'rjr_method_args' member variable (hash or array) and use the corresponding 'splat' operator appropriately, eg
Then you can define your handler like so:
|
@movitto It looks good! Thx, i'll try to fix my code! |
@movitto Hey, I corrected what was suggested. node.dispatcher.handle('hello') do |login: '', password: ''|
"Hello #{login} with #{password}"
end Unfortunately, for now I can't write a tests, because |
@WiRight a few things, could you rebase off the latest master and merge the patches into one? It seems like there is a bit of a back and forth with the changes in the different patches in this PR (you revert changes you made in the first patches in subsequent patches) Also we cannot convert the args to symbols in the way you do it as this presents an attack vector / vulnerability. Symbols are frozen strings, meaning they are never garbage collected, meaning an attacker could send alot of random messages with random parameters to cause a memory leak and crash the process. See: https://cwiki.apache.org/confluence/display/DTACLOUD/Preventing+memory+leaks+in+Ruby |
Okay, i'll check it and rewrite! |
Send raw
params
ofmethod
to handlerIt makes for methods like this
Params
in this case -> object positional parameters