-
Notifications
You must be signed in to change notification settings - Fork 238
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
Encapsulate dependencies on Devise (refactoring) #112
Merged
gonzalo-bulnes
merged 30 commits into
master
from
refactor-encapsulate-dependencies-on-devise
Sep 30, 2014
Merged
Encapsulate dependencies on Devise (refactoring) #112
gonzalo-bulnes
merged 30 commits into
master
from
refactor-encapsulate-dependencies-on-devise
Sep 30, 2014
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Define and use the method in `ActsAsTokenAuthenticationHandlerMethods`. Adds a little bit of duplication, yet I believe the change is worth it.
Define and use the method in `ActsAsTokenAuthenticationHandlerMethods`. Adds a little bit of duplication, yet I believe the change is worth it.
Both methods follow now the pattern: entity_{attribute}_{some_name}.
Add TokenComparator public interface specs Add TokenComparator private specs The dependency to the Devise secure comparison method is now encapsulated in the `ActsAsTokenAuthenticationHandler#token_comparator` method. If necessary, the `#token_correct?` specs could be written using a DummyTokenComparator instead of the Devise-dependent TokenComparator.
Add SignInHandler private specs (there is no public interface for now) The dependency to the Devise secure comparison method is now encapsulated in the `ActsAsTokenAuthenticationHandler#sign_in_handler` method. If necessary, the `#perform_sign_in!` specs could be written using a DummySignInHandler instead of the Devise-dependent SignInHandler.
Add FallbackAuthenticationHandler private specs (there is no public interface for now) The dependency on the Devise authentication helpers is now encapsulated in the `ActsAsTokenAuthenticationHandler#fallback_authentication_handler` method. If necessary, the `#authenticate_entity_from_fallback!` specs could be written using a DummyAuthenticationHandler instead of the Devise-dependent FallbackAuthenticationHandler.
And remove redundant `entity_name_underscore`
The `get_entity(name)` method allows to pass an Entity instance reference as argument of the methods defined through metaprogramming.
The token authenticatable model is no longer passed as argument of the authentication methods; its corresponding Entity is passed instead.
And remove redundant `entity_token_header_name`
And remove redundant `entity_identifier_header_name`
And remove redundant methods `entity_identifier/token_header_name`
c69e6c5
to
fc4c5cc
Compare
And remove redundant `get_token_from_params_or_headers`
And remove redundant `get_identifier_from_params_or_headers`
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As a developer
In order to make dependencies transparent
And to make the code testable in spite of them (see #104)
I want all dependencies to be properly encapsulated
And I want them to be injected in the methods that use them
Let's start with the (numerous) dependencies on Devise methods.
While doing that:
In order to make the code mode readable
And to make modifications easier
I want methods to be short
And their names to be descriptive