| Commit message (Collapse) | Author | Age | Files | Lines |
|\
| |
| |
| |
| |
| |
| |
| |
| | |
dmitriy-kiriyenko/fix-double-callback-in-same-statement
Prevent callback from being set twice.
Conflicts:
activesupport/CHANGELOG.md
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
When you add one callack in two separate `set_callback` calls - it is
only called once.
When you do it in one `set_callback` call - it is called twice.
This violates the principle of least astonishment for me. Duplicating
callback is usually an error. There is a correct and obvious way to do
anything without this "feature".
If you want to do
before_save :clear_balance, :calculate_tax, :clear_balance
or whatever, you should better do
before_save :carefully_calculate_tax
def carefully_calculate_tax
clear_balance
calculate_tax
clear_balance
end
And this even opens gates for some advanced refactorings, unlike the
first approach.
My assumptions are:
- Principle of least astonishment is violated, when callbacks are either
prevented from duplication, or not.
- Duplicating callbacks is usually an error. When it is intentional -
it's a smell of a bad design and can be approached without abusing
this "feature".
My suggestion is: do not allow duplicating callbacks in one callback
call, like it is not allowed in separate callbacks call.
|
|/ |
|
|
|
|
|
|
|
|
|
|
| |
Sometimes, on Mac OS X, programmers accidentally press Option+Space
rather than just Space and don’t see the difference. The problem is
that Option+Space writes a non-breaking space (0XA0) rather than a
normal space (0x20).
This commit removes all the non-breaking spaces inadvertently
introduced in the comments of the code.
|
| |
|
|
|
|
| |
It's sometimes hard to quickly find where deprecated call was performed, especially in case of migrating between Rails versions. So this is an attempt to improve the call stack part of the warning message by providing caller explicitly.
|
| |
|
| |
|
|
|
| |
This is a follow up to issue #7535
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
by Active Support)
Selecting which key extensions to include in active_support/rails
made apparent the systematic usage of Object#in? in the code base.
After some discussion in
https://github.com/rails/rails/commit/5ea6b0df9a36d033f21b52049426257a4637028d
we decided to remove it and use plain Ruby, which seems enough
for this particular idiom.
In this commit the refactor has been made case by case. Sometimes
include? is the natural alternative, others a simple || is the
way you actually spell the condition in your head, others a case
statement seems more appropriate. I have chosen the one I liked
the most in each case.
|
| |
|
|
|
|
|
| |
Deprecate usage of filter object with #before and #after
methods as around callback
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This reverts commits 911a0859ac065aa8e8834ac985353d659c7c7b65 and
30b31f51af6f7094c4a27b086755fc66c368d6fa.
Reason: these changes make the Active Model tests fail randomly.
Some examples:
http://travis-ci.org/#!/rails/rails/jobs/1498992
http://travis-ci.org/#!/rails/rails/jobs/1496948
http://travis-ci.org/#!/rails/rails/jobs/1489985
This script was used to reproduce these breaks:
https://gist.github.com/f6828a03ee4d40bffbc3
200 times, 0 failures
|
| |
|
|\
| |
| | |
AS::Callbacks remove useless code, improve performance
|
| | |
|
|/ |
|
| |
|
|\
| |
| |
| |
| | |
Conflicts:
activesupport/lib/active_support/callbacks.rb
|
| | |
|
|/ |
|
| |
|
| |
|
| |
|
|
|
|
|
|
| |
https://bugs.ruby-lang.org/projects/ruby-trunk/repository/revisions/34580
In this revision behavior of respond_to? had changed: now to ask about
protected method one should pass second argument `true`
|
| |
|
| |
|
|\
| |
| | |
AS::Callbacks#define_callbacks: add :terminate_after_callbacks option
|
| | |
|
|/ |
|
| |
|
| |
|
| |
|
| |
|
| |
|
|\
| |
| | |
AS::Callbacks::Callback refactor
|
| |
| |
| |
| |
| |
| | |
In order to make Callbacks code always operate on valid peaces of code
Concatenated Callback#start and Callback#end method into #apply
method.
|
| |
| |
| |
| |
| |
| | |
Runners are used internally.
This reverts commit 40c8aa706adbb60ff9d289016fb9020d48969fea.
|
| | |
|
| |
| |
| |
| |
| | |
Extracted `__reset_runner` from `__define_runner`
And call it in proper places
|
| | |
|
| | |
|
|/
|
|
| |
a before callback halts.
|
| |
|
| |
|
| |
|
|
|
|
|
| |
Incapsulate the logic of keyed callback method definition and execution
in the separated method.
|
|
|
|
|
|
| |
After a long list of discussion about the performance problem from using varargs and the reason that we can't find a great pair for it, it would be best to remove support for it for now.
It will come back if we can find a good pair for it. For now, Bon Voyage, `#among?`.
|
|
|
|
| |
suggestion!
|
|
|
|
| |
There're a lot of places in Rails source code which make a lot of sense to switching to Object#in? or Object#either? instead of using [].include?.
|