Method: Chef::Resource#notifies
- Defined in:
- lib/chef/resource.rb
#notifies(action, resource_spec, timing = :delayed) ⇒ Object
Sets up a notification that will run a particular action on another resource if and when this resource is updated by an action.
If the action does not update this resource, the notification never triggers.
Only one resource may be specified per notification.
‘delayed` notifications will only ever happen once per resource, so if multiple resources all notify a single resource to perform the same action, the action will only happen once. However, if they ask for different actions, each action will happen once, in the order they were updated.
‘immediate` notifications will cause the action to be triggered once per notification, regardless of how many other resources have triggered the notification as well.
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 |
# File 'lib/chef/resource.rb', line 242 def notifies(action, resource_spec, timing = :delayed) # when using old-style resources(:template => "/foo.txt") style, you # could end up with multiple resources. validate_resource_spec!(resource_spec) resources = [ resource_spec ].flatten resources.each do |resource| case timing.to_s when "delayed" notifies_delayed(action, resource) when "immediate", "immediately" notifies_immediately(action, resource) when "before" notifies_before(action, resource) else raise ArgumentError, "invalid timing: #{timing} for notifies(#{action}, #{resources.inspect}, #{timing}) resource #{self} "\ "Valid timings are: :delayed, :immediate, :immediately, :before" end end true end |