slack-ruby-client icon indicating copy to clipboard operation
slack-ruby-client copied to clipboard

Suggestion: Replace Hashie::Mash with OpenStruct

Open CodingAnarchy opened this issue 4 years ago • 3 comments

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!

CodingAnarchy avatar Mar 08 '21 23:03 CodingAnarchy

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

dblock avatar Mar 09 '21 14:03 dblock

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 #325.

jmanian avatar Apr 12 '21 22:04 jmanian

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

dblock avatar Apr 13 '21 00:04 dblock