aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/metal/instrumentation.rb
diff options
context:
space:
mode:
authorclaudiob <claudiob@gmail.com>2015-03-30 20:36:25 -0700
committerclaudiob <claudiob@gmail.com>2015-03-31 00:41:43 -0700
commit89389c7e72e8506fa461a36e4d1ff67366f9e61a (patch)
treed9b5238be1a5c8bba1d6c685814eda1b9595ea86 /actionpack/lib/action_controller/metal/instrumentation.rb
parent151aa690a2f62e2daee106079e88ff43cd770611 (diff)
downloadrails-89389c7e72e8506fa461a36e4d1ff67366f9e61a.tar.gz
rails-89389c7e72e8506fa461a36e4d1ff67366f9e61a.tar.bz2
rails-89389c7e72e8506fa461a36e4d1ff67366f9e61a.zip
Fix doc: set_callback also accepts an array of if:
When Active Record calls `set_callback` inside `after_commit`, [these lines of code](https://github.com/rails/rails/blob/master/activerecord/lib/active_record/transactions.rb#L276) pass an **array** of methods as the `:if` condition: ```ruby options[:if] = Array(options[:if]) options[:if] << "transaction_include_any_action?(#{fire_on})" ``` That made me realize that anyone could pass an **array** of `:if` and `:unless` conditions to `set_callback`, since Active Support transforms these conditions into an array anyways in [these lines of code](https://github.com/rails/rails/blob/master/activesupport/lib/active_support/callbacks.rb#L365): ```ruby @if = Array(options[:if]) @unless = Array(options[:unless]) ``` Long story short, this commit updates the documentation of the `set_callback` method to explain that arrays are also accepted. It also replaces +false+ and +true+ with false and true, since any _falsey_ or _truthy_ value will work. [ci skip]
Diffstat (limited to 'actionpack/lib/action_controller/metal/instrumentation.rb')
0 files changed, 0 insertions, 0 deletions