Skip to content
This repository was archived by the owner on May 5, 2020. It is now read-only.

Conversation

gregose
Copy link
Member

@gregose gregose commented Apr 28, 2014

This change provides the ability to specify a custom serializer for the CookieStore. In order to use serializers which only support base types, the FlashHash object has to support (de)serialization to/from plain Ruby hashes. FlashHash changes were made by porting over the Rails 2 portions of Envato's Rails 4 flash backport, h/t @charliesome .

/cc @josh @mastahyeti @ptoomey3 @dbussink

@gregose
Copy link
Member Author

gregose commented Apr 28, 2014

This also updates the AbstractStore to access hash keys with indifferent access, allowing for serializers that don't support serializing symbol keys.

@haileys
Copy link

haileys commented Apr 29, 2014

Cool. We'll also need to make sure we get these changes into the 3-0-github branch.

Copy link

Choose a reason for hiding this comment

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

What do we do in the Rails 3.x case?

Copy link
Member Author

Choose a reason for hiding this comment

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

For this branch we should only receive a FlashHash (only during transition period) or Hash. I still need to update 3.0 with 3.x specific changes.

Copy link

Choose a reason for hiding this comment

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

So if we're also changing 3.x to use a Rails 4 hash then we don't need to handle it specially here? OK, I see.

@btoews
Copy link

btoews commented Apr 29, 2014

🆒 I'm excited to see this happen. I'm wondering though if we could save ourselves some of the string vs sym key difficulties by using a HashWithIndifferentAccess?

@btoews
Copy link

btoews commented Apr 29, 2014

Alternatively, JSON.parse accepts :symbolize_names => true if we always wanted to have the keys symobolized.

@gregose
Copy link
Member Author

gregose commented Apr 29, 2014

I'm wondering though if we could save ourselves some of the string vs sym key difficulties by using a HashWithIndifferentAccess?

I thought about this, but appears that upstream Rails 4 has indifferent access but does not use HashWithIndifferentAccess: https://github.com/rails/rails/blob/master/actionpack/lib/action_dispatch/middleware/flash.rb. I have tried to stay consistent with upstream in f46a4ba.

@btoews
Copy link

btoews commented Apr 29, 2014

🆒

On Tue, Apr 29, 2014 at 5:23 PM, Greg Ose [email protected] wrote:

I'm wondering though if we could save ourselves some of the string vs sym
key difficulties by using a HashWithIndifferentAccess?

I thought about this, but appears that upstream Rails 4 has indifferent
access but does not use HashWithIndifferentAccess:
https://github.com/rails/rails/blob/master/actionpack/lib/action_dispatch/middleware/flash.rb.
I have tried to stay consistent with upstream in f46a4bahttps://github.com/github/rails/commit/f46a4bab085ef0221b8c6a4abfcfbf8c059ed15e
.


Reply to this email directly or view it on GitHubhttps://github.com//pull/64#issuecomment-41690455
.

-Ben Toews

Copy link

Choose a reason for hiding this comment

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

Above you are prefer the to_s ones, but here you prefer the non to_s one.

gregose added 3 commits May 7, 2014 14:27
Upstream doesnt support nested hashes having indifferent access, we
should stay consistent. Swap order for returned value in session hash.
Copy link
Member Author

Choose a reason for hiding this comment

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

@charliesome i dont think you bumped this last change

gregose added a commit that referenced this pull request May 16, 2014
Support custom serialization for Session::CookieStore
@gregose gregose merged commit 730e6a2 into 2-3-github May 16, 2014
@gregose gregose deleted the json-sessions branch May 16, 2014 05:07
@gregose gregose mentioned this pull request May 16, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants