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

Allow false in session#69

Merged
gregose merged 4 commits into2-3-githubfrom
allow-false-in-session
May 23, 2014
Merged

Allow false in session#69
gregose merged 4 commits into2-3-githubfrom
allow-false-in-session

Conversation

@gregose
Copy link
Copy Markdown
Member

@gregose gregose commented May 16, 2014

After #64, session objects accessed with a symbol would no longer be able to return false due to the return logic and would return nil. This explicitly checks for a nil return instead of something falsey.

This also updates update to stringify keys before the update.

@gregose
Copy link
Copy Markdown
Member Author

gregose commented May 16, 2014

@josh:

It sound like key presence isn't being implemented correctly.

I don't follow this. Is the issue that key? isn't implemented? I haven't added it because it is not implemented by stock rails either and wouldn't call load_for_read! if used before these changes. I wanted to only modify the portions of the Hash API already overridden here.

@gregose
Copy link
Copy Markdown
Member Author

gregose commented May 16, 2014

What about nil too?

This would only cause the symbol key value to be used instead of the nil value for the stringified key. I could rework this to (suggested by @ptoomey3):

def [](key)
  load_for_read!
  fetch(key.to_s, super(key))
end

That could return a nil value from a stringified key.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This will not nuke the symbol keys if they exist, right?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

If this is a hash with indiff access, we probably want deep_stringify_keys.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This will not nuke the symbol keys if they exist, right?

Correct, but since we prefer string keys on access, I don't think it should matter.

If this is a hash with indiff access, we probably want deep_stringify_keys.

We don't convert nested hashes to have string keys on access, so I do not think we should deep stringify. This is inline with not allowing symbols (or hashes with symbols) to be stored in the session object and the same principle followed as access within flash objects (keys can be symbols, but you cant store hashes w/ symbols).

gregose added a commit that referenced this pull request May 23, 2014
@gregose gregose merged commit 52abaed into 2-3-github May 23, 2014
@gregose gregose deleted the allow-false-in-session branch May 23, 2014 20:43
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.

3 participants