1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Fix example of index_with

- Clarify executor of `public_send`.
- Do not wrap `Interval.all_day` into [] since
  an array is expected as a returned value.

Related to #32523.

[ci skip]
This commit is contained in:
bogdanvlviv 2018-06-07 21:39:08 +03:00
parent 3573005517
commit 1ae1099ed4
No known key found for this signature in database
GPG key ID: E4ACD76A6DB6DFDD

View file

@ -2045,10 +2045,10 @@ The method `index_with` generates a hash with the elements of an enumerable as k
is either a passed default or returned in a block.
```ruby
%i( title body created_at ).index_with { |attr_name| public_send(attr_name) }
%i( title body created_at ).index_with { |attr_name| post.public_send(attr_name) }
# => { title: "hey", body: "what's up?", … }
WEEKDAYS.index_with([ Interval.all_day ])
WEEKDAYS.index_with(Interval.all_day)
# => { monday: [ 0, 1440 ], … }
```