summaryrefslogtreecommitdiff
path: root/lib/chef/resource.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chef/resource.rb')
-rw-r--r--lib/chef/resource.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/chef/resource.rb b/lib/chef/resource.rb
index ab955f5454..d74b942e7d 100644
--- a/lib/chef/resource.rb
+++ b/lib/chef/resource.rb
@@ -1088,10 +1088,30 @@ class Chef
# NOTE: that we do not support unregistering classes as descendents like
# we used to for LWRP unloading because that was horrible and removed in
# Chef-12.
+ # @deprecated
+ # @api private
alias :resource_classes :descendants
+ # @deprecated
+ # @api private
alias :find_subclass_by_name :find_descendants_by_name
end
+ # @deprecated
+ # @api private
+ # We memoize a sorted version of descendants so that resource lookups don't
+ # have to sort all the things, all the time.
+ # This was causing performance issues in test runs, and probably in real
+ # life as well.
+ @@sorted_descendants = nil
+ def self.sorted_descendants
+ @@sorted_descendants ||= descendants.sort_by { |x| x.to_s }
+ end
+ def self.inherited(other)
+ super
+ @@sorted_descendants = nil
+ end
+
+
# If an unknown method is invoked, determine whether the enclosing Provider's
# lexical scope can fulfill the request. E.g. This happens when the Resource's
# block invokes new_resource.