activesupport 7.0.0 → 7.0.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of activesupport might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aa0345240163d6b0d98012c437fc988d7c6b957264b42be1c095cb759ed0b102
4
- data.tar.gz: 3533cafb988ce3d2ace9b21f2a78d8bb76aeb6524ecc8b0d71743ee3af64c3c4
3
+ metadata.gz: f715e893b36942a3dd53bfdff6e441c8f2ec5aca48afe3b52b7b0592fd390f73
4
+ data.tar.gz: 796c266dacba0ee5373285437c0deb231a17dfa4ac1f071324061253d5f4c3cd
5
5
  SHA512:
6
- metadata.gz: 5e84aa52f105e68d791fc59101c3f288c86d21a0e26eccd5b3ef9643b82205811f0116055675dffa23c22f9ef126e5c3e52b6113332fd9b3540d90e80afca6a0
7
- data.tar.gz: bd68dd8c4eeebf5c956bb32e6617c2821dba0abdd344aa1f0b8e4f5f3674b1a5d1c3ea19d4b29f99222388ddeef164fcb2183c440af8bc1cab8a86e39aede24a
6
+ metadata.gz: 9567947d9506c123e68d78647f4912c4e21a957d014d0a7fca8cd37c72b06319f4c4849bb30a36205d5b0de73ef0837b97b86f5b43b68fa8b5fd6281c80fc7d3
7
+ data.tar.gz: 6da1c1833eedd6810577887eb28385c1a97ac61a7982ac7589a05717b73f42ae838f43228d54b0eb991bf7c9927935eb01ca8cc9f79772c572f1bae609ca9f12
data/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ ## Rails 7.0.1 (January 06, 2022) ##
2
+
3
+ * Fix `Class#descendants` and `DescendantsTracker#descendants` compatibility with Ruby 3.1.
4
+
5
+ [The native `Class#descendants` was reverted prior to Ruby 3.1 release](https://bugs.ruby-lang.org/issues/14394#note-33),
6
+ but `Class#subclasses` was kept, breaking the feature detection.
7
+
8
+ *Jean Boussier*
9
+
10
+
1
11
  ## Rails 7.0.0 (December 15, 2021) ##
2
12
 
3
13
  * Fix `ActiveSupport::Duration.build` to support negative values.
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2005-2021 David Heinemeier Hansson
1
+ Copyright (c) 2005-2022 David Heinemeier Hansson
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
@@ -3,24 +3,30 @@
3
3
  require "active_support/ruby_features"
4
4
 
5
5
  class Class
6
- # Returns an array with all classes that are < than its receiver.
7
- #
8
- # class C; end
9
- # C.descendants # => []
10
- #
11
- # class B < C; end
12
- # C.descendants # => [B]
13
- #
14
- # class A < B; end
15
- # C.descendants # => [B, A]
16
- #
17
- # class D < C; end
18
- # C.descendants # => [B, A, D]
19
- def descendants
20
- ObjectSpace.each_object(singleton_class).reject do |k|
21
- k.singleton_class? || k == self
6
+ if ActiveSupport::RubyFeatures::CLASS_SUBCLASSES
7
+ def descendants
8
+ subclasses.concat(subclasses.flat_map(&:descendants))
22
9
  end
23
- end unless ActiveSupport::RubyFeatures::CLASS_SUBCLASSES
10
+ else
11
+ # Returns an array with all classes that are < than its receiver.
12
+ #
13
+ # class C; end
14
+ # C.descendants # => []
15
+ #
16
+ # class B < C; end
17
+ # C.descendants # => [B]
18
+ #
19
+ # class A < B; end
20
+ # C.descendants # => [B, A]
21
+ #
22
+ # class D < C; end
23
+ # C.descendants # => [B, A, D]
24
+ def descendants
25
+ ObjectSpace.each_object(singleton_class).reject do |k|
26
+ k.singleton_class? || k == self
27
+ end
28
+ end
29
+ end
24
30
 
25
31
  # Returns an array with the direct children of +self+.
26
32
  #
@@ -1,11 +1,35 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Object
4
- # A duck-type assistant method. For example, Active Support extends Date
5
- # to define an <tt>acts_like_date?</tt> method, and extends Time to define
6
- # <tt>acts_like_time?</tt>. As a result, we can do <tt>x.acts_like?(:time)</tt> and
7
- # <tt>x.acts_like?(:date)</tt> to do duck-type-safe comparisons, since classes that
8
- # we want to act like Time simply need to define an <tt>acts_like_time?</tt> method.
4
+ # Provides a way to check whether some class acts like some other class based on the existence of
5
+ # an appropriately-named marker method.
6
+ #
7
+ # A class that provides the same interface as <tt>SomeClass</tt> may define a marker method named
8
+ # <tt>acts_like_some_class?</tt> to signal its compatibility to callers of
9
+ # <tt>acts_like?(:some_class)</tt>.
10
+ #
11
+ # For example, Active Support extends <tt>Date</tt> to define an <tt>acts_like_date?</tt> method,
12
+ # and extends <tt>Time</tt> to define <tt>acts_like_time?</tt>. As a result, developers can call
13
+ # <tt>x.acts_like?(:time)</tt> and <tt>x.acts_like?(:date)</tt> to test duck-type compatibility,
14
+ # and classes that are able to act like <tt>Time</tt> can also define an <tt>acts_like_time?</tt>
15
+ # method to interoperate.
16
+ #
17
+ # Note that the marker method is only expected to exist. It isn't called, so its body or return
18
+ # value are irrelevant.
19
+ #
20
+ # ==== Example: A class that provides the same interface as <tt>String</tt>
21
+ #
22
+ # This class may define:
23
+ #
24
+ # class Stringish
25
+ # def acts_like_string?
26
+ # end
27
+ # end
28
+ #
29
+ # Then client code can query for duck-type-safeness this way:
30
+ #
31
+ # Stringish.new.acts_like?(:string) # => true
32
+ #
9
33
  def acts_like?(duck)
10
34
  case duck
11
35
  when :time
@@ -51,7 +51,6 @@ module ActiveSupport
51
51
  unless @clear_disabled
52
52
  @clear_disabled = true
53
53
  remove_method(:subclasses)
54
- remove_method(:descendants)
55
54
  @@excluded_descendants = nil
56
55
  end
57
56
  end
@@ -87,9 +86,7 @@ module ActiveSupport
87
86
  end
88
87
 
89
88
  def descendants
90
- descendants = super
91
- descendants.reject! { |d| @@excluded_descendants[d] }
92
- descendants
89
+ subclasses.concat(subclasses.flat_map(&:descendants))
93
90
  end
94
91
 
95
92
  def direct_descendants
@@ -9,7 +9,7 @@ module ActiveSupport
9
9
  module VERSION
10
10
  MAJOR = 7
11
11
  MINOR = 0
12
- TINY = 0
12
+ TINY = 1
13
13
  PRE = nil
14
14
 
15
15
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  #--
4
- # Copyright (c) 2005-2021 David Heinemeier Hansson
4
+ # Copyright (c) 2005-2022 David Heinemeier Hansson
5
5
  #
6
6
  # Permission is hereby granted, free of charge, to any person obtaining
7
7
  # a copy of this software and associated documentation files (the
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activesupport
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.0.0
4
+ version: 7.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-12-15 00:00:00.000000000 Z
11
+ date: 2022-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n
@@ -359,10 +359,10 @@ licenses:
359
359
  - MIT
360
360
  metadata:
361
361
  bug_tracker_uri: https://github.com/rails/rails/issues
362
- changelog_uri: https://github.com/rails/rails/blob/v7.0.0/activesupport/CHANGELOG.md
363
- documentation_uri: https://api.rubyonrails.org/v7.0.0/
362
+ changelog_uri: https://github.com/rails/rails/blob/v7.0.1/activesupport/CHANGELOG.md
363
+ documentation_uri: https://api.rubyonrails.org/v7.0.1/
364
364
  mailing_list_uri: https://discuss.rubyonrails.org/c/rubyonrails-talk
365
- source_code_uri: https://github.com/rails/rails/tree/v7.0.0/activesupport
365
+ source_code_uri: https://github.com/rails/rails/tree/v7.0.1/activesupport
366
366
  rubygems_mfa_required: 'true'
367
367
  post_install_message:
368
368
  rdoc_options: