-
Notifications
You must be signed in to change notification settings - Fork 26
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
Feature request: better custom type representation #97
Comments
Hi @viralpraxis, thanks for checking out the gem and adding a featuring request! Maybe we can brainstorm a solution together. I think adding a configuration option that takes a list of classes/types that gets mapped to On the other hand, adding some way to load some monkeypatch could bridge the gap for folks looking to migrate from the old annotate gem. So I can see value there. Thoughts? |
I'm pretty sure this approach would do the trick. One thing I'm not sure about is how specific the configuration option should be. It might be as simple as classes_with_to_s_representation:
- Locale
- Region or it might be more flexible: custom_type_default_value_representation:
- class: "Locale"
methods: ["to_s", "inspect"] # value.to_s.inspect
- class: "Region"
methods: "to_s" # value.to_s No matter what we choose, we'll only have to slightly enhance |
@drwl Any thoughts? I'd be happy to contribute and implement any solution that will fix the issue. |
Apologies for the delay. I agree with your thoughts. I think the first approach could fit both the config file as a CLI option more easily. Perhaps we could make the key something like |
Adds configuration option to convert custom class types to their string representation. Will resolve #97
@viralpraxis I pushed up 4.7.0 to Rubygems if you want to give it a try. Feel free to reopen this if it doesn't work and thanks again for your help! |
@drwl with v4.7.0 everything works just as we expect, thank you for creating and maintaining this fork! 💎 By the way, looks like the changelog is corrupted a little bit: |
Thanks for pointing that out, I'll fix it |
Describe your problem here.
Commands
We've been using annotate for some time alongside with custom AR types (via
ActiveRecord::Type.register
). Unfortunately, annotate was serializing values of these types into extremely long strings:We workaround the issue by monkey-patching ``AnnotateModels.quote`:
so annotations were good to look at:
We are looking forward migration to annotaterb so we'd also want to get rid of that monkey-patch. Perhaps an addtional configuration option would be sufficient?
Version
The text was updated successfully, but these errors were encountered: