| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The perf gain is relatively minor but consistent:
```
Calculating -------------------------------------
0.zero? 137.091k i/100ms
1.zero? 137.350k i/100ms
0 == 0 142.207k i/100ms
1 == 0 144.724k i/100ms
-------------------------------------------------
0.zero? 8.893M (± 6.5%) i/s - 44.280M
1.zero? 8.751M (± 6.4%) i/s - 43.677M
0 == 0 10.033M (± 7.0%) i/s - 49.915M
1 == 0 9.814M (± 8.0%) i/s - 48.772M
```
And try! is quite a big hotspot for us so every little gain is appreciable.
|
| |
|
| |
|
|
|
|
|
|
| |
* Rename `ActiveSupport::Try` => `ActiveSupport::Tryable`
* Include the modules inline
* `private` indentation
|
|
|
|
|
|
|
|
|
|
|
|
| |
`Delegator` inherits from `BasicObject`, which means that it will not
have `Object#try` defined. It will then delegate the call to the
underlying object, which will not (necessarily) respond to the method
defined in the enclosing `Delegator`.
This patches `Delegator` with the `#try` method to work around the
surprising behaviour.
Fixes #5790
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
| |
Thanks @fbernier for suggestion! <3
At this moment we can use Module#prepend in all all cases
except of Range because of the bug [1] in MRI 2.2
[1] https://bugs.ruby-lang.org/issues/10847
|
| |
|
|
|
|
|
| |
Now that Rails requires Ruby >= 2.0, there is no need to check whether
`BigDecimal` exists or not.
|
| |
|
|\ |
|
| |
| |
| |
| |
| |
| | |
Also add doc examples for `Object.nil`.
[ci skip]
|
|/ |
|
|
|
|
|
|
|
|
| |
@rafaelfranca suggested in f7c7bcd9 that code examples should display
the result after `# =>` and not after `#=>`.
This commit replaces *all* the occurrences of `#=>` in the code documentation
(mostly added by me :sob:) with the suggested `# =>`.
|
| |
|
|
|
|
|
|
|
| |
@carlosantoniodasilva pointed out that when `@person` is nil then this would blow up when you ended up calling `#first`on `nil`.
> "there’s no way to break a try chain when you enter it :D"
[ci skip]
|
| |
|
|
|
|
|
|
|
|
|
|
| |
- better `if` example
- Added chaining example to the try method description
- Documented the `respond_to?` check to the try method description
- Clearer wording to explain that argument error is raised on argument mismatch to responding method, rather than to non-responding method (which is handled without exception by `try`)
- `.any?` is more precise than `! .blank?`
- Don't need to use `try` on `children` as (for regular associations) they will always be a collection or array that responds to `first`
- Fix typos/grammar
|
| |
|
|
|
|
| |
Based on commit 5e51bdda.
|
|
|
|
| |
options and original options have same keys
|
| |
|
|
|
|
| |
just needed some tenderloving instance_eval to fit the bill
|
| |
|
| |
|
| |
|
|
|
|
|
| |
Also moved comment for removal above `unless()` to not confuse RDoc with
the documentation for this method.
|
| |
|
| |
|
|
|
|
|
|
|
| |
Ruby 2.2 will include Kernel#itself so we don't need to define again.
See
https://github.com/ruby/ruby/commit/0a0160d6b659f6131a525fe1579e7c463d4c197e
|
|
|
|
| |
method name for Ruby 2.2
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
`Time#as_json`, `Date#as_json` and `DateTime#as_json` incorrectly depends on a
delegation that is set up in `active_support/json/encoding`. We cannot simply
require that file in `core_ext/object/json` because it would cause a circular
dependency problem (see #12203 for background). We should instead rely on AS's
autoload to load that file for us on-demand.
To trigger autoload correctly, we need to reference the `AS::JSON::Encoding`
constant instead of using the delegated version.
Fixes #16131.
|
|\
| |
| | |
Define Hash#to_query and set Hash#to_param as alias to it; with test cases
|
| | |
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
require `to_param`"
Revert "No need to require to_param, it is already required in to_query.rb"
This reverts commits ccdd97662e1fb00c23c90d59f65c091904959561
and d697ee14264a90a39cdbe87857656d8b314ac9b7.
Reason by @jeremy: These requires are not for implementation dependency.
They ensure that requiring array conversions provides to_query, to_param,
and other array conversion behaviors.
The fact that to_query is implemented in terms of to_param is just a
coincidence. If to_query removed its to_param require, then someone
requiring array conversions would no longer have to_param available.
This change removes these intentional dependencies on to_param in favor
of implementation side effects—an undesirable move that's susceptible to
regression.
|
|/ |
|
| |
|
| |
|
|\
| |
| | |
[Fixes #14948] Hash#to_query: right serialization for empty hash and array
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
are serialized
Empty Hash or Array should not present in serialization result
{a: []}.to_query # => ""
{a: {}}.to_query # => ""
For more info see #14948.
|
|/
|
|
| |
test case.
|
|
|
|
|
|
| |
1. Improve tests
2. Remove unnecessary constant
3. Add docs for BigDecimal#duplicable?
|
| |
|
|
|
|
| |
good, but the closer relationship to #presence over #present is ultimately worth it
|
| |
|