Method: Chef::Resource#subscribes
- Defined in:
- lib/chef/resource.rb
#subscribes(action, resources, timing = :delayed) ⇒ Object
Subscribes to updates from other resources, causing a particular action to run on this resource when the other resource is updated.
If multiple resources are specified, this resource action will be run if any of them change.
This notification will only trigger once, no matter how many other resources are updated (or how many actions are run by a particular resource).
341 342 343 344 345 346 347 348 349 350 351 352 353 354 |
# File 'lib/chef/resource.rb', line 341 def subscribes(action, resources, timing = :delayed) resources = [resources].flatten resources.each do |resource| validate_resource_spec!(resource) if resource.is_a?(String) resource = UnresolvedSubscribes.new(resource, run_context) end if resource.run_context.nil? resource.run_context = run_context end resource.notifies(action, self, timing) end true end |