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
Add No Touching #12772
Add No Touching #12772
Conversation
end | ||
end | ||
|
||
class << self |
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 is not this inside the ClassMethods
module?
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.
If I put them in the ClassMethods
module, I can't access them through NoTouching.apply_to
, like we do at line 22.
And it means the model gets the apply_to
and applied_to?
methods, while here, they're only in the module.
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.
Oh, right. Please put # :nodoc:
in the methods
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.
Done! 🌞
I think |
I like the fun of no_touching.
|
I like the sound of |
+1 for no_touch |
|
From experience the "fun" things in rails don't stick around (I'm thinking of the snowman for example). |
👍 |
Eh, what? Look up #forty_two. Do rename it back.
|
|
||
private | ||
def klasses | ||
@klasses ||= [] |
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.
This code is not thread safe. We need to store in a thread local variable.
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've fixed the thread safe problem.
Besides these few comments I just added, are we otherwise ready to merge? |
I just applied your two comments. |
I liked @steveklabnik's idea of calling it |
LOL Sent from my iPhone
|
@dmathieu this is very handy, however it seems after_touch callbacks still get run. Is there a way to disable after_touch callbacks? |
This adds
#no_touching
on all ActiveRecord models, allowing to ignore touching for the duration of a block.Example:
cc @dhh