forked from rails/rails
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
alias_attribute: handle user defined source methods
`alias_attribute` used to define a "jump method", e.g. `alias_attribute :foo, :bar` was pretty much a macro to generate ```ruby def foo bar end ``` This is convienient because it's easy, it doesn't impose an order of declaration or anything like that. But it's also much less efficient than a true `alias_method`. It also used to cause cache size explosion which we fixed in rails#52118, but making it behave like Ruby's `alias_method`, by doing a real alias. But this breaks some expectations (literally from the documentation): ```ruby attr_accessor :name attribute_method_suffix '_short?' define_attribute_methods :name alias_attribute :nickname, :name ``` Here we're not supposed to alias a generated method, but a user defined one. So this assumption can only hold for Active Record, not Active Model.
- Loading branch information
Showing
2 changed files
with
48 additions
and
3 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