From 5ece8327c9d67fa13ca00cce5749a960c643b247 Mon Sep 17 00:00:00 2001 From: Adam Leff Date: Fri, 2 Dec 2016 14:51:56 -0500 Subject: Deprecate creating properties whose names are already methods When creating a resource, a user can create a property that is the same name as an already-existing Ruby method, such as `#hash`. In the case of the `#hash` method, this can cause issues when attempting to adding resources to other data structures, such as Arrays or Hashes. In other examples, this could cause unexpected behavior that is incredibly difficult to troubleshoot. This change adds a deprecation warning in the case where a user adds a property to a resource that the resource instance already responds to. If y'all are OK with this approach, I'll be happy to write up the deprecation doc for this for docs.chef.io. Signed-off-by: Adam Leff --- lib/chef/deprecated.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'lib/chef/deprecated.rb') diff --git a/lib/chef/deprecated.rb b/lib/chef/deprecated.rb index 3a988fdfa3..2d352e4b1a 100644 --- a/lib/chef/deprecated.rb +++ b/lib/chef/deprecated.rb @@ -156,6 +156,26 @@ class Chef end end + class PropertyNameCollision < Base + def id + 11 + end + + def target + "property_name_collision.html" + end + end + + class LaunchdHashProperty < Base + def id + 12 + end + + def target + "launchd_hash_property.html" + end + end + class ChefPlatformMethods < Base def id 13 -- cgit v1.2.1