aws / aws/aws-record-ruby

Support for HashWithIndifferentAccess / Symbolized Keys

Open
#142 6 comments 0 reactions 0 assignees View on GitHub
feature-request
Dominant language
Ruby
Stars
318
Forks
43
Avg merge
19h
Merged PRs (30d)
1

Description

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](https://api.rubyonrails.org/classes/ActiveSupport/HashWithIndifferentAccess.html) 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).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.