Skip to content

Support for HashWithIndifferentAccess / Symbolized Keys #142

@thomaswitt

Description

@thomaswitt

One of the predominant use cases of this SDK is IMHO writing Rails applications. Therefore it would make sense that this SDK supports Rails conventions as much as much as possible. Unfortunately it doesn't do that currently in term of keys as symbols vs strings.

The desirable version
map_attr :my_data, default_value: { items: [] }

throws an error while, as the syntax required is
map_attr :my_data, default_value: { 'items' => [] }.

Same for ERB:
<% my_data.except(:name).keys.each do |key| %>

does not work but needs to be
<% my_data.except("name").keys.each do |key| %>

This is very un-rails-y, both in models as in views, as using HashWithIndifferentAccess gives you at least both options. If you don't want to support this out of the box due to the dependency to ActiveSupport, I would at least making an option when ActiveSupport is available (or automatically use it).

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature-requestA feature should be added or improved.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions