-
Notifications
You must be signed in to change notification settings - Fork 21.6k
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
make changed_attributes work with new enum feature #13489
Conversation
@@ -180,7 +180,6 @@ def attribute_change(attr) | |||
# Handle <tt>*_will_change!</tt> for +method_missing+. | |||
def attribute_will_change!(attr) | |||
return if attribute_changed?(attr) | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add this back?
I'm not sure if doing this from the (Sorry - I haven't looked into this enough to suggest a good alternative approach yet, just adding my concerns for now) |
I agree that it's better to override |
What does everyone think of this? It'd great to |
|
||
def enum_attribute?(attr_name) | ||
klass = self | ||
return false unless defined?(klass::ENUMS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why can't just use self::ENUMS
here and in other places using klass?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I cargo culted from the enum
method right below. I wanted to follow the convention that the rest of the module was using.
end | ||
end | ||
|
||
private | ||
def _enum_methods_module | ||
@_enum_methods_module ||= begin | ||
mod = Module.new | ||
mod = Module.new do | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kill newlines after block indentions here and anywhere else as well.
Would this impact the solution we had to dealing with form fields and enums? |
def enum(definitions) | ||
klass = self | ||
klass.const_set("ENUMS", ActiveSupport::HashWithIndifferentAccess.new) unless defined?(klass::ENUMS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's leave this (and the related code) out of this PR, I'll tackle that in #13450
Changed per the discussion in PR #13267.