Creating directories, including paths, from variables

I am aware that I can create directories including their parent paths like this:

%w[ /foo /foo/bar /foo/bar/baz ].each do |path|
  directory path do
     action: create
  end
end

However, I would l like to initially store my path in a variable

foo_bar_baz_path='/foo/bar/baz'

Then create the directory and parent directories if they don’t exist. I can’t use this:

directory foo_bar_baz_path do
  action :create
end

But I was hoping someone knows some Ruby magic that will allow me to do this? I am actually working Windows, so my path is D:\foo\bar\baz.

Thanks!

Use the recursive flag in the directory resource