OodFilesApp.candidate_favorite_paths.tap do |paths|
# add project space directories
projects = User.new.groups.map(&:name).grep(/^P./)
paths.concat projects.map { |p| FavoritePath.new("/fs/project/#{p}") }
# add User scratch space directory
paths << FavoritePath.new("/fs/scratch/#{User.new.name}")
# Project scratch is given an optional title field
paths.concat projects.map { |p| FavoritePath.new("/fs/scratch/#{p}", title: "Scratch") }
end
So, I don’t understand how this does what it does.
What is the “tap” attribute of OodFilesApp.candidate_favorite_paths? This is a method? So nothing will happen in this initializer without doing something with method “tap?”
I don’t need anything this complicated w/r/t building a dynamic list of favorites every time the user opens the dashboard. It only needs exactly one path (/mnt/data) – in fact, I don’t even want the user’s home. How can this be accomplished?
tap, and the way we’re using it here, is sort of a ruby idiom. Sort of a ‘give me this thing (paths) and let me operate on that thing’ - without having to keep it as a variable or similar.
In any case - this should work for you.
OodFilesApp.candidate_favorite_paths.tap do |paths|
paths << FavoritePath.new("/mnt/data")
end
This much simpler form may actually work for you, but I’m only like 80% sure without actually trying it out.