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

Prefix / Suffix feature request #173

Open
borisrorsvort opened this issue Nov 22, 2023 · 2 comments
Open

Prefix / Suffix feature request #173

borisrorsvort opened this issue Nov 22, 2023 · 2 comments

Comments

@borisrorsvort
Copy link

Would it be possible to introduce prefix/suffix options for attribute names in jsonb_accessor? This would allow developers to write more concise and readable code, particularly when dealing with multiple attributes.

For example, instead of writing:

jsonb_accessor :voting_options,
               voting_options_type:        [:string, { default: VOTING_OPTIONS_TYPES[0], store_key: :type }],
               voting_options_min_votes:   [:integer, { store_key: :min_votes }],
               ...

we could have:

jsonb_accessor :voting_options,
               type:        [:string, { default: VOTING_OPTIONS_TYPES[0], suffix: true }],
               ...

This addition would not only streamline code but also maintain readability and ease of maintenance.

I understand the complexities involved in maintaining an open-source project and adding new features. If this suggestion aligns with your vision for the gem, I'd be delighted to see it implemented.

@haffla
Copy link
Contributor

haffla commented Nov 22, 2023

Hey @borisrorsvort,

thanks. Sure I would welcome such addition to the code if it only changes the name of the getter and setter methods.

Your above example would generate

  • voting_options_type
  • voting_options_type=

instead of

  • type
  • type=

correct?

@borisrorsvort
Copy link
Author

yes! but it would still be stored as type inside the json on the column voting_options.

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

No branches or pull requests

2 participants