1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activesupport
claudiob 89389c7e72 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]
2015-03-31 00:41:43 -07:00
..
bin Pass symbol as an argument instead of a block 2014-11-29 11:53:24 +01:00
lib Fix doc: set_callback also accepts an array of if: 2015-03-31 00:41:43 -07:00
test Require the extensions to tests pass in isolation 2015-03-30 13:59:50 -03:00
activesupport.gemspec Target Ruby 2.2.1 in gemspecs 2015-03-09 09:56:26 +01:00
CHANGELOG.md Revert "Remove Array#inquiry" 2015-03-30 13:38:13 -03:00
MIT-LICENSE Update copyright notices to 2015 [ci skip] 2014-12-31 08:34:14 +01:00
Rakefile Follow up to #16613 2014-09-28 12:04:06 +02:00
README.rdoc Feature requests should be made on the mailing list, not submitted to 2014-06-01 19:11:39 -07:00

= Active Support -- Utility classes and Ruby extensions from Rails

Active Support is a collection of utility classes and standard library
extensions that were found useful for the Rails framework. These additions
reside in this package so they can be loaded as needed in Ruby projects
outside of Rails.


== Download and installation

The latest version of Active Support can be installed with RubyGems:

  % [sudo] gem install activesupport

Source code can be downloaded as part of the Rails project on GitHub:

* https://github.com/rails/rails/tree/master/activesupport


== License

Active Support is released under the MIT license:

* http://www.opensource.org/licenses/MIT


== Support

API documentation is at:

* http://api.rubyonrails.org

Bug reports can be filed for the Ruby on Rails project here:

* https://github.com/rails/rails/issues

Feature requests should be discussed on the rails-core mailing list here:

* https://groups.google.com/forum/?fromgroups#!forum/rubyonrails-core