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

Suggestion: Replace Hashie::Mash with OpenStruct #371

Open
CodingAnarchy opened this issue Mar 8, 2021 · 3 comments
Open

Suggestion: Replace Hashie::Mash with OpenStruct #371

CodingAnarchy opened this issue Mar 8, 2021 · 3 comments

Comments

@CodingAnarchy
Copy link

Hashie has generally been noted as having lackluster performance, large memory overhead, and results in a few pitfalls. For instance, see https://www.schneems.com/2014/12/15/hashie-considered-harmful.html.

OpenStruct objects can provide much of the same benefits (e.g. attributes accessible by symbol or string keys, as well as method calls) with less overhead and easier understanding. I tried doing this myself, but some of the Slack client is partially dependent on some strange behavior around Hashie::Mash (particularly on recursive hashes within a Slack::Messages::Message) - this could all be changed, but I felt it was getting to be a larger effort that should have community buy-in before being done. As a result, I figured I would raise this suggestion here. Thanks!

@dblock
Copy link
Collaborator

dblock commented Mar 9, 2021

I support this change. It should be probably similar to what we did in Grape, so maybe not OpenStruct.

@jmanian
Copy link
Collaborator

jmanian commented Apr 12, 2021

I also support this.

@dblock What are the advantages of ActiveSupport::HashWithIndifferentAccess over OpenStruct? I see two disadvantages:

  1. HashWithIndifferentAccess doesn't allow method access, which might be a painful refactor for a lot of people (me included).
  2. This library would need to add back ActiveSupport, which was removed in Remove activesupport dependency #325.

@dblock
Copy link
Collaborator

dblock commented Apr 13, 2021

I don't really have any strong feelings about ActiveSupport::HashWithIndifferentAccess over OpenStruct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants