aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/object/try.rb
Commit message (Collapse)AuthorAgeFilesLines
* Use == 0 instead of .zero? in #tryJean Boussier2015-08-171-1/+1
| | | | | | | | | | | | | | | | | | | 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.
* Small stylistic tweaks for `Delegator#try` patchGodfrey Chan2015-05-191-5/+5
| | | | | | * Rename `ActiveSupport::Try` => `ActiveSupport::Tryable` * Include the modules inline * `private` indentation
* Patch `Delegator` to work with `#try`Nate Smith2015-05-191-17/+57
| | | | | | | | | | | | `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
* Fix a few typos [ci skip]Robin Dupret2015-01-031-1/+1
|
* Add docs for `Object.nil!`claudiob2014-12-221-3/+9
| | | | | | Also add doc examples for `Object.nil`. [ci skip]
* Replace `#=>` with `# =>` [ci skip]claudiob2014-12-171-2/+2
| | | | | | | | @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 `# =>`.
* Revert a change made to the example in 1ac4525Godfrey Chan2014-10-241-1/+1
| | | | | | | @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]
* Include return value in examples added in #17378 [ci skip]Zachary Scott2014-10-241-2/+2
|
* Improved try documentation [ci skip]Eugene Gilburg2014-10-241-8/+25
| | | | | | | | | | - 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
* DRY up try/try!Ari Pollak2014-10-231-10/+6
|
* Bring try! into parity with try.Ari Pollak2014-10-221-1/+1
| | | | Based on commit 5e51bdda.
* We tenderized the wrong method! Object#try already had the yield option, ↵David Heinemeier Hansson2014-08-291-1/+10
| | | | just needed some tenderloving instance_eval to fit the bill
* Fixes typo in Object#try!Jay Hayes2013-09-101-1/+1
|
* Revert "Merge branch 'master' of github.com:rails/docrails"Vijay Dev2013-08-171-1/+1
| | | | | | | This reverts commit 70d6e16fbad75b89dd1798ed697e7732b8606fa3, reversing changes made to ea4db3bc078fb3093ecdddffdf4f2f4ff3e1e8f9. Seems to be a code merge done by mistake.
* Fixes typo in Object#try!Jay Hayes2013-07-261-1/+1
|
* revamps the RDoc of Object#tryXavier Noria2013-01-281-22/+30
|
* Bring back changelog entries for Active SupportCarlos Antonio da Silva2012-08-111-2/+2
| | | | Removed in 0228a73b1094a3e19ad291d2ce4789890c09578a, pull request #7310.
* Add Object#try! with the old NoMethodError raising behaviorDavid Heinemeier Hansson2012-07-271-0/+14
|
* will now return nil instead of raise a NoMethodError if the receiving ↵David Heinemeier Hansson2012-07-271-1/+4
| | | | object does not implement the method
* remove double hyphen that doesn't allow properly parsingFrancesco Rodriguez2012-06-041-5/+1
|
* Improve docs for `try` by adding note on `BasicObject`Piotr Sarnacki2012-05-201-0/+4
| | | | [ci skip] closes #5790
* Update docs to public_send for Object#tryOscar Del Ben2012-05-131-1/+1
|
* update docs on Object#tryVasiliy Ermolovich2012-05-131-1/+1
|
* Object#try can't call private methodsVasiliy Ermolovich2012-05-121-2/+2
|
* Revert "don't raise NoMethodError the tried method doesn't exists"José Valim2011-10-061-2/+0
| | | | This reverts commit 29a5aeaae976bf8432d57ec996c7c81932a39de6.
* don't raise NoMethodError the tried method doesn't existsdmathieu2011-05-211-0/+2
|
* NilClass is a singletonAkira Matsuda2011-04-201-1/+1
|
* oops fixed typoSebastian Martinez2011-04-181-1/+1
|
* Fixed docs for NilClass#trySebastian Martinez2011-04-181-8/+8
|
* Formatting docsSebastian Martinez2011-04-171-1/+1
|
* Docs for NilClass#trySebastian Martinez2011-04-171-1/+13
|
* Active Support typos.R.T. Lechow2011-03-051-1/+1
|
* :method: is not needed when RDoc can detect itSantiago Pastorino2010-12-021-5/+0
|
* Add support for try to just yield the object to a block if no method is to ↵raggi2010-11-141-1/+13
| | | | be called. Kind of like a tap_if_present.
* Remove dummy method definition in favor of RDoc hints:Aaron Patterson2010-09-111-7/+5
| | | | http://rdoc.rubyforge.org/RDoc/Parser/Ruby.html
* try is an object extensionJeremy Kemper2009-03-211-0/+36