Skip to content

Add prefix to attribute definition #43

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

maximebedard
Copy link
Contributor

Whilst adding accessor: false, I thought it would be convenient to add prefix to attributes as well. It also fixes #7.

Thoughts?

@byroot @rafaelfranca

@rafaelfranca
Copy link
Collaborator

LGTM

@coveralls
Copy link

coveralls commented Jun 13, 2016

Coverage Status

Coverage decreased (-0.09%) to 94.617% when pulling d5d757c on maximebedard:add-prefix into fff4ec5 on byroot:master.

@coveralls
Copy link

coveralls commented Jun 13, 2016

Coverage Status

Coverage decreased (-0.3%) to 94.418% when pulling 9fb6b33 on maximebedard:add-prefix into fff4ec5 on byroot:master.


it 'defines accessors' do
expect(model).to respond_to :preferences_language
expect(model).to respond_to :preferences_language=
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a test to make sure language and language= are not defined?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, I need to look into how the attribute definition works as well. The values does not seem to be set correctly. I'll ping back once I've figured it out.

@casperisfine casperisfine force-pushed the master branch 3 times, most recently from a9ea2c5 to 97478f7 Compare December 3, 2019 11:25
@natematykiewicz
Copy link

Typed Store looks great! It would really be a good fit to simplify something my team did a long time ago. The one thing that's stopping me from using it is the :prefix option (specifically with a string/symbol prefix). This PR seems very close, except that the regular ActiveRecord Store allows prefix: :foo instead of prefix: true, to prefix the methods with 'foo_' instead of the field name.

Is there anything I can do to help get this PR out and get the string/symbol prefix complete?

Here's the relevant ActiveRecord code. https://github.com/rails/rails/blob/de53ba56cab69fb9707785a397a59ac4aaee9d6f/activerecord/lib/active_record/store.rb#L112-L120

Thanks!

@casperisfine
Copy link
Collaborator

Is there anything I can do to help get this PR out and get the string/symbol prefix complete?

This PR is very outdated, but if you feel like submitting a similar one that is rebased, I'll review it.

@natematykiewicz
Copy link

Sounds good. Thanks, Jean!

@dwillett
Copy link
Contributor

I was also looking for this functionality as well, so I went ahead and rebased and put up a PR at #91

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

Successfully merging this pull request may close these issues.

Manage several serialized hash with same key.
7 participants