Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34761 from kamipo/require-ruby-2.5
Use native `Array#append`, `Array#prepend`, `Hash#transform_keys`, and `Hash#transform_keys!`
- Loading branch information
Showing
11 changed files
with
6 additions
and
181 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 2 additions & 6 deletions
8
activesupport/lib/active_support/core_ext/array/prepend_and_append.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
class Array | ||
# The human way of thinking about adding stuff to the end of a list is with append. | ||
alias_method :append, :push unless [].respond_to?(:append) | ||
require "active_support/deprecation" | ||
|
||
# The human way of thinking about adding stuff to the beginning of a list is with prepend. | ||
alias_method :prepend, :unshift unless [].respond_to?(:prepend) | ||
end | ||
ActiveSupport::Deprecation.warn "Ruby 2.5+ (required by Rails 6) provides Array#append and Array#prepend natively, so requiring active_support/core_ext/array/prepend_and_append is no longer necessary. Requiring it will raise LoadError in Rails 6.1." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,11 @@ | ||
# frozen_string_literal: true | ||
|
||
require "abstract_unit" | ||
require "active_support/core_ext/array" | ||
|
||
class PrependAppendTest < ActiveSupport::TestCase | ||
def test_append | ||
assert_equal [1, 2], [1].append(2) | ||
end | ||
|
||
def test_prepend | ||
assert_equal [2, 1], [1].prepend(2) | ||
def test_requiring_prepend_and_append_is_deprecated | ||
assert_deprecated do | ||
require "active_support/core_ext/array/prepend_and_append" | ||
end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters