-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve attribute methods generation
I'm currently working through Ruby warnings in our app, and one of the top source is from ActiveModel Serializer sub classes. Usually they look like: ``` class SomethingSerializer < AMS attributes :title, :body def title # method redefinition warning titleize end end ``` One solution would be to call `attributes` at the end of the method, so that `attributes` skips defining these, but it's quite unatural. Instead we can use the self alias trick to mark these generated methods as OK to redefine. An alternative would be to define them in an included module like Active Model does, but not sure if it's worth it. While I was at it, I improved the way these methods are generated.
- Loading branch information
Showing
3 changed files
with
21 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters