Move signature logic to its own module#195
Conversation
Removed secure_compare specs as it is not part of the public API anymore. HMAC specs should already cover the functionality of secure_compare.
|
Thank you very much! This is exactly the way to go. 👍 |
|
|
||
| module JWT | ||
| module Signature | ||
| extend self |
There was a problem hiding this comment.
Please use module_function instead of extend self
There was a problem hiding this comment.
what about private functions? I don't think it's possible to define private function with module_functions.
What are the benefits of module_functions?
There was a problem hiding this comment.
Using module_function is the preferred coding style.
You're alway able to define a function as private by using this syntax:
def my_fun(my_param) do
puts my_param
end
private :my_funThere was a problem hiding this comment.
I don't think module_function respects the private visibility.
module A
module_function
def my_fun(my_param)
puts my_param
end
private :my_fun
end
A.my_fun("calling private method") #=> "calling private method"
excpt
left a comment
There was a problem hiding this comment.
Please merge the current master into your branch. There have been changes. The small issues are commented inline.
|
Thanks for the comments @excpt This branch is already up-to-date with master, sorry I missed In my opinion the constants Do you still think it's worth moving the constants to |
|
Agreed. Move the algorithms into the signature module. This makes way more sense. The rest is looking fine. After that change i'll merge your PR. Thanks again. 🍻 |
|
After looking through the last refactoring to move logic out of the jwt.rb monolith I think the better solution to that problem is to rewrite the module as a class. The Encoding and Verify refactorings took the same approach. This will give you full control about what's private logic and what should be exposed to the outside. |
|
I think normally a class is meant to have both behavior and state. In this case, So, if you implement And I think @excpt do you still prefer to implement this as a class? would you use instance or class methods? |
|
I totally over-engineered the problem. Sorry. Thank you very much for the contribution and your patience to withstand my pretty silly review. 👍 The code solves the problem and this is what counts. |
|
@EmilioCristalli |
Not sure if this change was planned, but seemed aligned with the rest of modules the gem has.
Also I think this will help to start working on redefining the public API (I guess that is planned for version 2).
Let me know what you think, if you want me to make changes, or if it's just not the direction you guys wanted to go.
Thanks!