aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext
Commit message (Collapse)AuthorAgeFilesLines
* [Active Support] require_relative => requireAkira Matsuda2017-10-2159-188/+188
| | | | This basically reverts 8da30ad6be34339124ba4cb4e36aea260dda12bc
* Let Hash#slice return a HashAkira Matsuda2017-10-211-1/+1
| | | | | | | In order to keep this method compatible with the Ruby 2.5 version of Hash#slice. This bahavior is actually slightly incompatibile with previous versions of Active Support but it might not cause a real problem, since HWIA, the biggest use case of Hash subclassing here, already overrides `slice` to return another HWIA.
* Move HWIA specific logic for slice and slice! to HWIA classAkira Matsuda2017-10-211-2/+0
|
* Hash#slice is in Ruby 2.5+Akira Matsuda2017-10-211-1/+1
| | | | since r60229
* Remove obsolete documentation [ci skip]Max Felsher2017-10-191-3/+0
| | | | | Instructions to use `h` or `html_escape` in ERB templates were added to `actionpack/lib/action_view/template_handlers/erb.rb` in a1b0349 (Rails 2.1), but ERB has automatically escaped values since Rails 3.
* Fix `to_s(:db)` for range comprising of alphabets.Aditya Kapoor2017-10-161-1/+7
|
* Fix formatting of `Time.use_zone` [ci skip]yuuji.yaginuma2017-10-041-4/+4
|
* Remove redundant require_relative "module/anonymous" and "module/reachable"bogdanvlviv2017-09-171-3/+0
|
* Deprecate `Module#reachable?` methodbogdanvlviv2017-09-171-0/+1
|
* Hash#transform_keys is in Ruby 2.5+Akira Matsuda2017-09-011-2/+2
| | | | since r59328
* Self-alias doesn't suppress the warning on Ruby 2.2Matthew Draper2017-09-011-8/+17
|
* Clarify intentions around method redefinitionsMatthew Draper2017-09-019-54/+69
| | | | | | | | | Don't use remove_method or remove_possible_method just before a new definition: at best the purpose is unclear, and at worst it creates a race condition. Instead, prefer redefine_method when practical, and silence_redefinition_of_method otherwise.
* Update links to use https instead of http [ci skip]Yoshiyuki Hirano2017-08-221-1/+1
|
* faster implementation of Hash#deep_mergeM. Simon Borg2017-08-161-12/+6
| | | | | | | | | | | | add missing newline call #deep_merge instead of #dup.deep_merge! make variable and parameter naming more consistent change `_key` to `key` faster implementation of Hash#deep_merge
* Test for the new exception of delegate_missing_to (#30191)Anton Khamets2017-08-121-3/+9
| | | | | | | | | | | | | | | * Add test for the new exception of delegate_missing_to * Add a changelog entry * Only check for nil if NoMethodError was raised * Make method private * Have to pass both target name and value * Inline the re-raise [Rafael Mendonça França + Anton Khamets]
* Extend image_tag to accept ActiveStorage Attachments and Variants (#30084)Anton Khamets2017-08-071-0/+2
| | | | | | | | | | | | | | | | | | * Extend image_tag to accept ActiveStorage's Attachments and Variants * Flip resolve_image_source around * Add tests for the new use-cases of image_tag * Remove the higher-level test * Update image_tag documentation * Add error states into the test suite * Re-raise polymorhic_url's NoMethodError as ArgumentError * delegate_missing_to will raise DelegationError instead of NoMethodError
* Remove unused `LoadError::REGEXPS` constantyuuji.yaginuma2017-08-041-7/+0
| | | | since 4ad1a52, `LoadError::REGEXPS` is no longer needed.
* Update String#camelize to provide feedback when wrong option is passedRicardo Díaz2017-08-021-0/+2
| | | | | | | | | String#camelize was returning nil without any feedback when an invalid option was passed as parameter. This update makes the method to raises an ArgumentError when the option passed is invalid, similar to what Ruby does for String#downcase (and others) in 2.4.1. https://ruby-doc.org/core-2.4.1/String.html#method-i-downcase
* Merge pull request #29758 from glaucocustodio/patch-1 [ci skip]Sean Griffin2017-07-171-0/+10
|\ | | | | Add documentation for class_attribute default option
| * Add documentation for class_attribute optionsGlauco Custódio2017-07-171-0/+10
| |
* | Merge branch 'master' into make-reverse-merge-bang-order-consistentSean Griffin2017-07-17114-311/+633
|\ \
| * | [Active Support] `rubocop -a --only Layout/EmptyLineAfterMagicComment`Koichi ITO2017-07-11114-0/+114
| |/
| * Merge pull request #29728 from kirs/frozen-activesupportMatthew Draper2017-07-09114-0/+114
| |\ | | | | | | Use frozen-string-literal in ActiveSupport
| | * Use frozen-string-literal in ActiveSupportKir Shatrov2017-07-09114-0/+114
| | |
| * | Use `map` in `delegate` so that actual prefixed method names are returned, ↵Krzysztof Zych2017-07-051-1/+1
| |/ | | | | | | if using prefix version.
| * [Active Support] require => require_relativeAkira Matsuda2017-07-0159-187/+187
| |
| * Use mattr_accessor default: option throughout the projectGenadi Samokovarov2017-06-031-1/+1
| |
| * Implement mattr_acessor :default optionGenadi Samokovarov2017-06-031-24/+19
| |
| * Add next occur and previous occurred day of week API (#26600)Shota Iguchi2017-05-301-0/+16
| |
| * Add option for class_attribute default (#29270)David Heinemeier Hansson2017-05-291-2/+11
| | | | | | | | | | | | | | | | | | | | | | | | * Allow a default value to be declared for class_attribute * Convert to using class_attribute default rather than explicit setter * Removed instance_accessor option by mistake * False is a valid default value * Documentation
| * Assorted delegate_missing_to doc fixesT.J. Schuck2017-05-041-22/+17
| | | | | | | | | | | | | | | | | | | | | | | | * Fix rdoc code formatting — `tt`, not backticks * Fix/simplify sentence grammar — should at least just be “and the like”, not “likes”, but this is just general tightening up. * Add note that delegated methods must be public. Tested here: https://github.com/rails/rails/blob/7ff5ccae94ce2aff76b5f8a31a28e305a047d642/activesupport/test/core_ext/module_test.rb#L359-L365 * Simplify example code for delegate_missing_to. The example had complexity that wasn’t necessary for demonstrating `delegate_missing_to`. This gets rid of a bunch of cruft so the example is more obvious about what’s going on regarding the feature itself. [ci skip]
| * Add missing require for `remove_possible_method`Eugene Kenny2017-04-281-0/+1
| | | | | | | | | | | | https://github.com/rails/rails/commit/505537082849d912e8e29819655b80a573e93c0c added a call to `remove_possible_method`, but didn't require the file that defines it.
| * Add commaJon Moss2017-04-201-1/+1
| | | | | | | | [ci skip]
| * Fix Enumerable#sum redefined warningFumiaki MATSUSHIMA2017-04-181-23/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If we require 'active_support/core_ext/enumerable' on Ruby 2.4, we'll see following warning because `Enumerable#sum` and `Array#sum` are added in Ruby 2.4. ``` rails/rails/activesupport/lib/active_support/core_ext/enumerable.rb:20: warning: method redefined; discarding old sum ``` The minimal way to fix the warning is `alias sum sum`. ``` $ ruby -v ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux] $ ruby -w -e "def a; end; def a; end" -e:1: warning: method redefined; discarding old a -e:1: warning: previous definition of a was here $ ruby -w -e "def a; end; alias a a; def a; end" ``` But this behavior is not intended. (@amatsuda was told by @ko1) So we should use `alias` as a meaningful way. Ruby 2.4's `sum` (`orig_sum`) assumes an `identity` is `0` when we omit `identity` so we can delegate to `orig_sum` with explicit `identity` only. In a strict sense, we can detect `identity` by check instance's class but we don't care at this time about that because calling `Enumerable#sum` is rare. In many cases, we will call `Array#sum`.
| * Add missing periodsJon Moss2017-04-171-2/+2
| | | | | | | | [ci skip]
| * Add (more) documentation to to_timeKen Mayer2017-04-171-0/+3
| | | | | | | | | | There's a difference in the results between `Date#to_time(:local)` and `Date#in_time_zone` but it is subtle and can confuse users (like me :-).
| * Merge pull request #28638 from bogdanvlviv/prepend_and_append_in_rubyKasper Timm Hansen2017-04-151-2/+2
| |\ | | | | | | Prevent aliases Array#append and Array#prepend
| | * Prevent aliases Array#append and Array#prependbogdanvlviv2017-04-021-2/+2
| | | | | | | | | | | | https://github.com/ruby/ruby/commit/f57d515d69b7a35477b9ba5d08fe117df1f1e275
| * | Add additional options to time `change` methodsAndrew White2017-04-141-15/+21
| | | | | | | | | | | | | | | | | | | | | Support `:offset` in `Time#change` and `:zone` or `:offset` in `ActiveSupport::TimeWithZone#change`. Fixes #28723.
| * | delegate_missing_to should fall back to superMatthew Draper2017-04-091-1/+1
| | |
| * | delegate_to_missing doesn't delegate private methodsMatthew Draper2017-04-091-1/+4
| |/ | | | | | | So we shouldn't claim they're there, even when asked explicitly.
| * Add aliases for reverse_merge to with_defaultsMatt Casper2017-03-291-0/+2
| | | | | | | | | | | | In the context of controller parameters, reverse_merge is commonly used to provide defaults for user input. Having an alias to reverse_merge called with_defaults feels more idiomatic for Rails.
| * Use keyword arguments instead of hashRafael Mendonça França2017-03-281-4/+4
| |
| * Merge pull request #28480 from ↵Rafael Mendonça França2017-03-281-9/+19
| |\ | | | | | | | | | | | | | | | mubashirhanif/add_keep_id_suffix_option_to_humanize_new Add keep id suffix option to humanize new
| | * Added options hash to titleize method and keep_id_suffix option to humanizeMubashir Hanif2017-03-211-9/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | some documentation remove extra whitespace. Added id in the middle test case and corrected some testcases. Some Coding standard guidelines corrections as suggested by codeclimate. Some more corrections suggested by codeclimate.
| * | Fix doc format for `duplicable?` [ci skip]yuuji.yaginuma2017-03-251-6/+6
| | |
| * | Remove unnecessary ruby version comments [ci skip]Vipul A M2017-03-241-2/+2
| | |
| * | Fix duplicable? for Ratiional and Complex on ruby master, since they are now ↵Vipul A M2017-03-231-12/+22
| | | | | | | | | | | | duplicable
| * | Cleanup documentation fixes (#28460)Vipul A M2017-03-171-2/+2
| | |
| * | Merge pull request #28445 from denniszelada/feature-documentation-with_optionsVipul A M2017-03-171-0/+11
| |\ \ | | | | | | | | Add documentation to use with_options anywhere in the same class [ci