def new_style_notification(notify)
      # Given `notifies :restart, "service[foo]"` the target is the
      # `"service[foo]"` string portion.
      target_path = 'args_add_block/args_add/descendant::
        tstring_content[count(ancestor::dyna_symbol) = 0]/@value'
      target = notify.xpath("arg_paren/#{target_path} | #{target_path}").to_s

      # Test the target string against the standard syntax for a new-style
      # notification: `resource_type[resource_name]`.
      match = target.match(/^([^\[]+)\[(.*)\]$/)
      return nil unless match

      # Convert the captured resource type and name to symbols.
      resource_type, resource_name =
        match.captures.tap { |m| m[0] = m[0].to_sym }

      # Normally the `resource_name` will be a simple string. However in the
      # case where it has an embedded sub-expression then we will return the
      # AST to the caller to handle.
      if notify.xpath("descendant::string_embexpr").empty?
        return nil if resource_name.empty?
      else
        resource_name =
          notify.xpath("args_add_block/args_add/string_literal")
      end
      { resource_name: resource_name, resource_type: resource_type }
    end
def new_style_notification(notify)
      # Given `notifies :restart, "service[foo]"` the target is the
      # `"service[foo]"` string portion.
      target_path = 'args_add_block/args_add/descendant::
        tstring_content[count(ancestor::dyna_symbol) = 0]/@value'
      target = notify.xpath("arg_paren/#{target_path} | #{target_path}").to_s

      # Test the target string against the standard syntax for a new-style
      # notification: `resource_type[resource_name]`.
      match = target.match(/^([^\[]+)\[(.*)\]$/)
      return nil unless match

      # Convert the captured resource type and name to symbols.
      resource_type, resource_name =
        match.captures.tap { |m| m[0] = m[0].to_sym }

      # Normally the `resource_name` will be a simple string. However in the
      # case where it has an embedded sub-expression then we will return the
      # AST to the caller to handle.
      if notify.xpath("descendant::string_embexpr").empty?
        return nil if resource_name.empty?
      else
        resource_name =
          notify.xpath("args_add_block/args_add/string_literal")
      end
      { resource_name: resource_name, resource_type: resource_type }
    end
Extract the `:resource_name` and `:resource_type` from a new-style
 notification.