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

Break up the cookies classes #1024

Merged
merged 3 commits into from
Jan 8, 2019
Merged

Break up the cookies classes #1024

merged 3 commits into from
Jan 8, 2019

Conversation

dwightwatson
Copy link
Contributor

@dwightwatson dwightwatson commented Jan 7, 2019

Description of the Change

This was done in response to #1014.

  • The various cookie classes in the cookie module are broken out into their own files.
  • The ChainedStore module is just rolled into Amber::Router::Cookies where it is used.
  • The SerializedStore and JsonSerializer are removed as there don't appear to be references to them.

I'm sure there is still work that can be done to cleanup this code, but I think this is a good first step.

Alternate Designs

Leaving it in a single file as it was, or breaking it out to multiple files but keeping the old stuff around as well.

Benefits

It'll be much easier to reason with and work with the cookie related code. It will also make it easier to attempt to DRY up any of the code that can be.


There appear to be test failures - but I'm not sure they are related. Would love a second opinion/point in the right direction. I'm having trouble replicating test failures locally - I don't know if it's something with my setup or something that I'm doing wrong.

@eliasjpr
Copy link
Contributor

eliasjpr commented Jan 7, 2019

@dwightwatson the tests failures are related to these changes and it seems that the changes here might have broken the CLI. Try generating a new app with these changes and make sure the app runs successfully.

@eliasjpr
Copy link
Contributor

eliasjpr commented Jan 7, 2019

I like the breakdown of the classes and moving in the right direction. Maybe abstract the duplication of methods

@dwightwatson
Copy link
Contributor Author

I've merged master in after #1027 and the suite has gone back to green.

I've broken out an AbstractStore which matches the convention for session stores. It defines abstract methods get and set - which identified that the PermanentStore didn't actually conform to the protocol unlike the other stores - so I've updated it appropriately.

Copy link
Member

@drujensen drujensen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@drujensen drujensen requested review from a team January 7, 2019 22:36
set(name, value)
end

abstract def get(name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd use this opportunity to change it to get?. This way we have a free #[]? and a cheaper way to handle non-existent keys.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If possible, I'd rather tackle that sort of improvement in another PR. The focus of this one was to break up the classes, remove dead code and have it all still work.

src/amber/router/cookies/store.cr Show resolved Hide resolved
Copy link
Member

@robacarp robacarp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

excellent refactor @dwightwatson thank you

@robacarp robacarp merged commit 3693c58 into amberframework:master Jan 8, 2019
@dwightwatson dwightwatson deleted the cookies branch January 8, 2019 03:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants