diff options
author | Noah Kantrowitz <noah@coderanger.net> | 2016-07-28 17:14:20 -0700 |
---|---|---|
committer | Noah Kantrowitz <noah@coderanger.net> | 2016-07-28 17:14:20 -0700 |
commit | 56af1a3713cd4f408c2c1d8658961c7b5df73192 (patch) | |
tree | 6248ef8714479e577dd3fefe17f76dde154905f1 /lib | |
parent | 259be7a0cb3f7d7f7ee4d0f49211ddc8d9dcc1b9 (diff) | |
download | chef-56af1a3713cd4f408c2c1d8658961c7b5df73192.tar.gz |
So this was less vestigial than we thought. Those Chef::Resource
instances are created when subscribing against a string key.
Leaving the conditionals removed, but adding a new stubby class to
streamline things and a note on the RunContext side so we might
remember how this works next time.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/chef/resource.rb | 14 | ||||
-rw-r--r-- | lib/chef/run_context.rb | 9 |
2 files changed, 22 insertions, 1 deletions
diff --git a/lib/chef/resource.rb b/lib/chef/resource.rb index 262aa84781..479eb0a7e2 100644 --- a/lib/chef/resource.rb +++ b/lib/chef/resource.rb @@ -260,6 +260,18 @@ class Chef end # + # Token class to hold an unresolved subscribes call with an associated + # run context. + # + # @api private + # @see Resource#subscribes + class UnresolvedSubscribes < self + # The full key ise given as the name in {Resource#subscribes} + alias_method :to_s, :name + alias_method :declared_key, :name + end + + # # Subscribes to updates from other resources, causing a particular action to # run on *this* resource when the other resource is updated. # @@ -326,7 +338,7 @@ class Chef resources = [resources].flatten resources.each do |resource| if resource.is_a?(String) - resource = Chef::Resource.new(resource, run_context) + resource = UnresolvedSubscribes.new(resource, run_context) end if resource.run_context.nil? resource.run_context = run_context diff --git a/lib/chef/run_context.rb b/lib/chef/run_context.rb index 89247d46bb..7ef476c44b 100644 --- a/lib/chef/run_context.rb +++ b/lib/chef/run_context.rb @@ -194,6 +194,9 @@ class Chef # @param [Chef::Resource::Notification] The notification to add. # def notifies_before(notification) + # Note for the future, notification.notifying_resource may be an instance + # of Chef::Resource::UnresolvedSubscribes when calling {Resource#subscribes} + # with a string value. before_notification_collection[notification.notifying_resource.declared_key] << notification end @@ -203,6 +206,9 @@ class Chef # @param [Chef::Resource::Notification] The notification to add. # def notifies_immediately(notification) + # Note for the future, notification.notifying_resource may be an instance + # of Chef::Resource::UnresolvedSubscribes when calling {Resource#subscribes} + # with a string value. immediate_notification_collection[notification.notifying_resource.declared_key] << notification end @@ -212,6 +218,9 @@ class Chef # @param [Chef::Resource::Notification] The notification to add. # def notifies_delayed(notification) + # Note for the future, notification.notifying_resource may be an instance + # of Chef::Resource::UnresolvedSubscribes when calling {Resource#subscribes} + # with a string value. delayed_notification_collection[notification.notifying_resource.declared_key] << notification end |