aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/callbacks.rb
Commit message (Collapse)AuthorAgeFilesLines
...
* | | fixing more variable namesAaron Patterson2013-05-101-10/+10
| | |
* | | fix variable nameAaron Patterson2013-05-101-6/+6
| | |
* | | reduce the number of lambasAaron Patterson2013-05-101-5/+2
| | |
* | | callback sequence is no longer usedAaron Patterson2013-05-101-6/+0
| | |
* | | no need for variable assignments, just pass the values inAaron Patterson2013-05-101-6/+2
| | |
* | | make_lambda is never called with an ArrayAaron Patterson2013-05-101-2/+0
| | |
* | | callbacks are wrapped with lambdasAaron Patterson2013-05-101-106/+76
| | |
* | | remove dead codeAaron Patterson2013-05-101-10/+0
| | |
* | | fix method namesAaron Patterson2013-05-101-40/+44
| | |
* | | using lambas for the callback bodiesAaron Patterson2013-05-101-32/+12
| | |
* | | wrap all options in lambasAaron Patterson2013-05-101-7/+13
| | |
* | | conditions in callbacks return consistent lambdasAaron Patterson2013-05-101-9/+43
|/ /
* | use public send on the scope parametersAaron Patterson2013-05-081-1/+1
| |
* | using strings as scopes is not used anywhere, so remove itAaron Patterson2013-05-081-1/+1
| |
* | adding tests for lambdas as conditionsAaron Patterson2013-05-081-1/+1
| |
* | separate identification computationAaron Patterson2013-05-081-24/+18
| |
* | separate filters from source codeAaron Patterson2013-05-081-20/+31
| |
* | if the callbacks are not the same class, they cannot be duplicatesAaron Patterson2013-05-081-2/+6
| |
* | fix object comparison caseAaron Patterson2013-05-081-1/+5
| |
* | polymorphic comparison operatorAaron Patterson2013-05-081-11/+24
| |
* | fix issue #10502, do not recompute method name for already-stringified ↵Sean Walbran2013-05-071-1/+1
| | | | | | | | object filter
* | Revert "Merge pull request #10433 from ↵Jon Leighton2013-05-031-33/+11
| | | | | | | | | | | | | | | | | | | | wangjohn/making_callbacks_more_performant" This reverts commit 09751fdc847c25237891a8fcb0c2312e39bbe86d, reversing changes made to 6a5ab08d21c4284a05f5e34484b18a91d4e5c50c. This change caused a failure in actionpack/test/abstract/callbacks_test.rb.
* | Improving the performance of callbacks by keeping a hash of thewangjohn2013-05-021-11/+33
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | callbacks in the CallbackChain, so you don't have to iterate over all callbacks when checking for duplicates. Benchmark results when the tests in activerecord/test/cases/associations_test.rb were run with and without the change: == On master (when scanning all of the callbacks): --------------------------------------------------------- % cumulative self self total time seconds seconds calls ms/call ms/call name --------------------------------------------------------- 1.85 9.26 0.82 18412 0.04 0.05 ActiveSupport::Callbacks::Callback#matches? 1.22 12.32 0.54 18412 0.03 0.08 ActiveSupport::Callbacks::Callback#duplicates? 0.93 14.61 0.41 19600 0.02 0.21 ActiveSupport::Callbacks::CallbackChain#remove_duplicates Finished tests in 1.217065s, 30.4010 tests/s, 53.4072 assertions/s. --------------------------------------------------------- == On my branch (when using a hash to check callback duplication): --------------------------------------------------------- % cumulative self self total time seconds seconds calls ms/call ms/call name --------------------------------------------------------- 0.15 29.63 0.06 1188 0.05 0.72 ActiveSupport::Callbacks::CallbackChain#handle_duplicates 0.00 40.50 0.00 84 0.00 0.12 ActiveSupport::Callbacks::Callback#matches? 0.00 40.50 0.00 84 0.00 0.12 ActiveSupport::Callbacks::Callback#duplicates? 0.00 40.50 0.00 91 0.00 0.22 ActiveSupport::Callbacks::CallbackChain#scan_and_remove_duplicates Finished tests in 1.117757s, 33.1020 tests/s, 58.1522 assertions/s. ---------------------------------------------------------
* refactor initialization of arrayVipul A M2013-04-231-4/+1
|
* remove redundant variableVipul A M2013-04-221-2/+0
|
* Merge pull request #10096 from benofsky/fix_skipping_object_callback_filtersRafael Mendonça França2013-04-211-2/+23
|\ | | | | Fixes skipping object callback filters
| * Fixes skipping object callback filtersBen McRedmond2013-04-041-2/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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?`.
* | extract array to a constantVipul A M2013-04-221-1/+3
| |
* | Revert "Merge pull request #10034 from ↵Rafael Mendonça França2013-04-041-13/+1
| | | | | | | | | | | | | | | | | | 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
* | Fixes skipping object callback filtersBen McRedmond2013-04-041-1/+13
|/ | | | | | | | | | | | | | | 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?`.
* change merge to merge!Vipul A M2013-03-291-1/+1
|
* only calculate next_id when we need a new method definedAaron Patterson2013-03-041-1/+2
|
* Merge pull request #7376 from ↵Rafael Mendonça França2012-12-211-5/+29
|\ | | | | | | | | | | | | | | | | dmitriy-kiriyenko/fix-double-callback-in-same-statement Prevent callback from being set twice. Conflicts: activesupport/CHANGELOG.md
| * Prevent callback from being set twice.Dmitriy Kiriyenko2012-12-201-5/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | attempt to fix slow runner name methodMax Shytikov2012-12-191-1/+10
|/
* Replace comments' non-breaking spaces with spacesclaudiob2012-12-041-2/+2
| | | | | | | | | | 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.
* Make caller attribute in deprecation methods optionalAlexey Gaziev2012-10-301-2/+2
|
* Provide a call stack for deprecation warnings where needed.Nikita Afanasenko2012-10-291-2/+5
| | | | 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.
* update AS docs [ci skip]Francesco Rodriguez2012-09-171-75/+80
|
* AS::Callbacks: deprecate monkey patch of object callbacksBogdan Gusiev2012-09-071-0/+1
|
* Fixed around callback with lambda exampleAaron Renner2012-09-061-1/+1
| | | This is a follow up to issue #7535
* removes usage of Object#in? from the code base (the method remains defined ↵Xavier Noria2012-08-061-2/+1
| | | | | | | | | | | | | | | | | | | 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.
* fix typo in documentationAnatoly Makarevich2012-07-261-1/+1
|
* AS::Callbacks: deprecate monkey patch codeBogdan Gusiev2012-06-261-1/+2
| | | | | Deprecate usage of filter object with #before and #after methods as around callback
* Revert some ActiveSupport::Callbacks changes.Rafael Mendonça França2012-06-011-3/+16
| | | | | | | | | | | | | | | | | 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: fix run_callbacks for objects with negative idBogdan Gusiev2012-05-181-1/+1
|
* Merge pull request #6351 from bogdan/callbacksJosé Valim2012-05-171-16/+3
|\ | | | | AS::Callbacks remove useless code, improve performance
| * AS::Callbacks remove useless code, improve performanceBogdan Gusiev2012-05-161-16/+3
| |
* | AS::Callbacks: simplify logical statementBogdan Gusiev2012-05-171-2/+2
|/
* removing unnecessary 'examples' noise from activesupportFrancesco Rodriguez2012-05-131-2/+0
|