Make sure raise error if you try to overwrite field name that is already defined in Object#185
Make sure raise error if you try to overwrite field name that is already defined in Object#185harada4atsushi wants to merge 2 commits intoactive-hash:masterfrom
Conversation
|
I don't know why we cannot use these names as attributes...(even if just a warning). |
|
@syguer I haven't read the source code enough yet, so I don't know the details, but if I define it with same name as a method of the Object class, It seems the Object class to be executed at runtime. I checked the behavior of ActiveRecord. create_table :countries do |t|
t.string :display
t.timestamps
endclass Country < ApplicationRecord
endcountry = Country.new(display: 'hoge')
country.display
# => "hoge"ActiveRecord seems to be overwritten with the defined field name. |
|
I have found the relevant part, so write it down for the time being. If I remove the I tried to read what implementation of |
|
@harada4atsushi |
…ady defined in Object
cd61ad3 to
0f61455
Compare
|
@syguer Apparently, it seems to be a change to avoid overriding the methods implemented in the class when defining fields using ActiveYaml. This is not limited ActiveYaml, methods implemented in classes that inherit from ActiveHash::Base should not be overwritten by Therefore, it has been changed to |
|
sorry, this is old but simple. Not sure why it stalled.
I like this solution and it looks pretty good. Any thoughts? |
|
Modifying a class in a Still concerned about hierarchical classes and the |
From the request of #184 , an error is generated when you try to overwrite the method already defined in Object.
Is it better to use warnings instead of errors because the impact is great?