aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/callbacks.rb
Commit message (Collapse)AuthorAgeFilesLines
* 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
|
* Merge branch 'master' of github.com:lifo/docrailsVijay Dev2012-05-121-8/+0
|\ | | | | | | | | Conflicts: activesupport/lib/active_support/callbacks.rb
| * deleting empty lines in docs partsFrancesco Rodriguez2012-05-101-8/+0
| |
* | AS::Callbacks#run_callbacks remove key argumentFrancesco Rodriguez2012-05-101-2/+1
|/
* AS::Callbacks optimized to reduce call backtraceBogdan Gusiev2012-04-271-7/+7
|
* fix doc for ActiveSupport::Callbacks::Callback#define_conditional_callbackJan Xie2012-04-081-1/+1
|
* AS::Callbacks: deprecate rescuable optionBogdan Gusiev2012-02-221-26/+1
|
* sync __run_callbacks with ruby-trunkSokolov Yura2012-02-141-1/+1
| | | | | | 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: remove unused codeBogdan Gusiev2012-02-051-17/+13
|
* AS::Callbacks: rip out per_key option.Bogdan Gusiev2012-02-041-34/+13
|
* Merge pull request #4866 from bogdan/terminate_after_callbacksJosé Valim2012-02-041-1/+6
|\ | | | | AS::Callbacks#define_callbacks: add :terminate_after_callbacks option
| * AS::Callbacks: :skip_after_callbacks_if_terminated optionBogdan Gusiev2012-02-031-1/+6
| |
* | AC::Callbacks: remove usage of :per_key option from filtersBogdan Gusiev2012-02-031-2/+2
|/
* Fix GH #4344. A defined callback in extended module is called too.kennyj2012-01-241-1/+1
|
* Remove unused argument.kennyj2012-01-221-3/+3
|
* AS::Callbacks: Refactor :per_key optionBogdan Gusiev2012-01-171-35/+7
|
* AS::Callbacks: remove unused runnerBogdan Gusiev2012-01-121-16/+3
|
* Remove Array.wrap calls in ActiveSupportRafael Mendonça França2012-01-061-8/+7
|
* Merge pull request #3637 from bogdan/compile_optionsJosé Valim2012-01-051-58/+62
|\ | | | | AS::Callbacks::Callback refactor
| * AS::Callbacks::Callback refactorBogdan Gusiev2011-11-151-58/+62
| | | | | | | | | | | | In order to make Callbacks code always operate on valid peaces of code Concatenated Callback#start and Callback#end method into #apply method.
* | Revert "AS::Callbacks: remove __define_runner"José Valim2012-01-041-3/+16
| | | | | | | | | | | | Runners are used internally. This reverts commit 40c8aa706adbb60ff9d289016fb9020d48969fea.
* | AS::Callbacks: remove __define_runnerBogdan Gusiev2011-12-301-16/+3
| |
* | Refactor AS::CallbacksBogdan Gusiev2011-12-281-6/+8
| | | | | | | | | | Extracted `__reset_runner` from `__define_runner` And call it in proper places
* | AS::Callbacks: improved __define_runner performanceBogdan Gusiev2011-12-251-3/+2
| |
* | AS::Callbacks: improve __define_runner perfomanceBogdan Gusiev2011-12-251-10/+11
| |
* | Log 'Filter chain halted as CALLBACKNAME rendered or redirected' every time ↵José Valim2011-11-301-4/+14
|/ | | | a before callback halts.
* AS::Callbacks::Callback#_compile_option refactoredBogdan Gusiev2011-11-111-14/+12
|
* AS::Callbacks.__run_keyed_callback: remove unused cacheBogdan Gusiev2011-11-101-10/+6
|
* self.class.name -> self.name (we are already inside a class).José Valim2011-11-101-1/+1
|
* AS::Callbacks#_define_runner refactoredBogdan Gusiev2011-11-101-23/+22
| | | | | Incapsulate the logic of keyed callback method definition and execution in the separated method.
* Remove `#among?` from Active SupportPrem Sichanugrist2011-04-131-1/+1
| | | | | | 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?`.
* Change Object#either? to Object#among? -- thanks to @jamesarosen for the ↵David Heinemeier Hansson2011-04-121-1/+1
| | | | suggestion!
* Using Object#in? and Object#either? in various placesPrem Sichanugrist2011-04-111-1/+2
| | | | 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?.