aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/object
Commit message (Collapse)AuthorAgeFilesLines
* Improve readability of docs by using code tag [ci skip]amitkumarsuroliya2015-09-242-3/+3
|
* Short-circuit `blank?` on date and time valuesAndrew White2015-09-211-0/+11
| | | | | | | The concept of a blank date or time doesn't make sense so we can short circuit the calls for `blank?` on these classes to gain small speed boost. Fixes #21657
* File encoding is defaulted to utf-8 in Ruby >= 2.1Akira Matsuda2015-09-181-2/+0
|
* docs, make `blank?` behavior clear. Closes #21468. [ci skip]Yves Senn2015-09-021-2/+2
|
* 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.
* Tiny documentation edits [ci skip]Robin Dupret2015-07-281-1/+1
|
* improve duplicable documentation [ci skip]Julio Lopez2015-07-101-1/+5
|
* 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
* deep_dup method, remove old key from duplicated hash to avoid unnecessary pairsMehmet Emin İNAÇ2015-05-041-0/+1
|
* [ci skip] Remove unnecessary `>`yui-knk2015-03-311-1/+1
|
* Mark some constants as nodoc and remove unneeded namespaceRafael Mendonça França2015-03-201-11/+9
|
* Use Module#prepend instead of alias_method_chainKir Shatrov2015-03-201-12/+16
| | | | | | | 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
* Remove some comments about Ruby 1.9 behaviorsRafael Mendonça França2015-01-041-1/+1
|
* Remove hack to support BigDecimal in Ruby 1.9claudiob2015-01-041-11/+2
| | | | | Now that Rails requires Ruby >= 2.0, there is no need to check whether `BigDecimal` exists or not.
* Fix a few typos [ci skip]Robin Dupret2015-01-031-1/+1
|
* Merge branch 'master' of github.com:rails/docrailsVijay Dev2015-01-031-3/+9
|\
| * Add docs for `Object.nil!`claudiob2014-12-221-3/+9
| | | | | | | | | | | | Also add doc examples for `Object.nil`. [ci skip]
* | Removed Object#itself as it's implemented in ruby 2.2Cristian Bica2014-12-291-15/+0
|/
* 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 `# =>`.
* Pass symbol as an argument instead of a blockErik Michaels-Ober2014-11-293-3/+3
|
* 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.
* [ci skip] Add Doc of with_options for the case when inherited default ↵Pramod Sharma2014-10-181-1/+15
| | | | options and original options have same keys
* Methods are not duplicable.Peter Jaros2014-09-031-0/+10
|
* We tenderized the wrong method! Object#try already had the yield option, ↵David Heinemeier Hansson2014-08-292-15/+12
| | | | just needed some tenderloving instance_eval to fit the bill
* Use instance_eval on @tenderlove's suggestion :trollface:David Heinemeier Hansson2014-08-291-4/+5
|
* Update examples to show real worthDavid Heinemeier Hansson2014-08-291-1/+1
|
* Added yield to Object#presenceDavid Heinemeier Hansson2014-08-291-1/+12
|
* Add documentation intro to example for `Object#itself`.Zachary Scott2014-08-191-2/+5
| | | | | Also moved comment for removal above `unless()` to not confuse RDoc with the documentation for this method.
* Fix AS docs / changelog with wrong method [ci skip]Carlos Antonio da Silva2014-08-051-1/+1
|
* Update itself.rb [ci skip]Jon Atack2014-08-051-1/+1
|
* Only define Objetc#itself when it is not definedRafael Mendonça França2014-08-041-8/+10
| | | | | | | Ruby 2.2 will include Kernel#itself so we don't need to define again. See https://github.com/ruby/ruby/commit/0a0160d6b659f6131a525fe1579e7c463d4c197e
* Rename Object#self to Object#itself to have parity with matz sanctioned ↵David Heinemeier Hansson2014-08-011-2/+2
| | | | method name for Ruby 2.2
* Added Object#self which returns the object itselfDavid Heinemeier Hansson2014-08-011-0/+10
|
* Add implicit receiver support to `Object#with_options`Pavel Pravosud2014-07-291-2/+15
|
* Fixed a compatibility issue with the `Oj` gemGodfrey Chan2014-07-291-3/+3
| | | | | | | | | | | | | `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.
* Merge pull request #15629 from akshay-vishnoi/test-to_paramRafael Mendonça França2014-07-282-66/+59
|\ | | | | Define Hash#to_query and set Hash#to_param as alias to it; with test cases
| * Move to_param to to_query, also Improve testsAkshay Vishnoi2014-06-202-66/+59
| |
* | [ci skip] BigDecimal#duplicable? returns false in 1.9.xAkshay Vishnoi2014-06-131-1/+1
| |
* | Revert "remove unnecssary require of `to_param`, as `to_query` is already ↵Rafael Mendonça França2014-06-111-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | No need to require to_param, it is already required in to_query.rbAkshay Vishnoi2014-06-111-1/+0
|/
* Do not check defined?(CGI) on every call #to_queryprintercu2014-05-131-1/+1
|
* No need the else clauseRafael Mendonça França2014-05-041-2/+0
|
* Merge pull request #14949 from bogdan/empty-hash-array-parameterizationRafael Mendonça França2014-05-041-6/+6
|\ | | | | [Fixes #14948] Hash#to_query: right serialization for empty hash and array
| * [Fixes #14948] Hash#to_query: Changed a way how empty hash and empty array ↵Bogdan Gusiev2014-05-031-6/+6
| | | | | | | | | | | | | | | | | | | | | | are serialized Empty Hash or Array should not present in serialization result {a: []}.to_query # => "" {a: {}}.to_query # => "" For more info see #14948.
* | Remove deprecated file(`active_support/core_ext/object/to_json.rb`) and its ↵Kuldeep Aggarwal2014-05-041-5/+0
|/ | | | test case.