Method: Chef::Resource#notifies

Defined in:
lib/chef/resource.rb

#notifies(*args) ⇒ Object



231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
# File 'lib/chef/resource.rb', line 231

def notifies(*args)
  unless ( args.size > 0 && args.size < 4)
    raise ArgumentError, "Wrong number of arguments for notifies: should be 1-3 arguments, you gave #{args.inspect}"
  end

  if args.size > 1 # notifies(:action, resource) OR notifies(:action, resource, :immediately)
    add_notification(*args)
  else
    # This syntax is so weird. surely people will just give us one hash?
    notifications = args.flatten
    notifications.each do |resources_notifications|
      resources_notifications.each do |resource, notification|
        action, timing = notification[0], notification[1]
        Chef::Log.debug "adding notification from resource #{self} to `#{resource.inspect}' => `#{notification.inspect}'"
        add_notification(action, resource, timing)
      end
    end 
  end
rescue NoMethodError
  Chef::Log.fatal("Error processing notifies(#{args.inspect}) on #{self}")
  raise
end