| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
| |
|
| |
|
|\
| |
| | |
Fixes skipping object callback filters
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
This allows you to skip callbacks that are defined by objects, e.g. for
`ActionController`:
skip_after_filter MySpecialFilter
Previously this didn't work due to a bug in how Rails compared callbacks
in `Callback#matches?`. When a callback is compiled, if it's an object
filter (i.e. not a method, proc, etc.), `Callback` now defines a method on
`@klass` that is derived from the class name rather than `@callback_id`.
So, when `skip_callback` tries to find the appropriate callback to
remove, `Callback` can regenerate the method name for the filter
object and return the correct value for `Callback#matches?`.
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
benofsky/fix_skipping_object_callback_filters"
This reverts commit c79c6980647eb76bfa52178711fb04ba7e9d403b, reversing
changes made to ba4c27479add60b783a0e623c8a5d176c1dc9043.
This broke all the tests. See https://travis-ci.org/rails/rails/builds/6061839
|
|/
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This allows you to skip callbacks that are defined by objects, e.g. for
`ActionController`:
skip_after_filter MySpecialFilter
Previously this didn't work due to a bug in how Rails compared callbacks
in `Callback#matches?`. When a callback is compiled, if it's an object
filter (i.e. not a method, proc, etc.), `Callback` now defines a method on
`@klass` that is derived from the class name rather than `@callback_id`.
So, when `skip_callback` tries to find the appropriate callback to
remove, `Callback` can regenerate the method name for the filter
object and return the correct value for `Callback#matches?`.
|
| |
|
| |
|
|\
| |
| |
| |
| |
| |
| |
| |
| | |
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
|