I am writing a Rake script which consists of tasks with arguments. I figured out how to pass arguments and how to make a task dependent on other tasks.
task :pa
Setting attributes seems to work like a charm too.
Just ensure the the task dependency is set to the task that sets the attributes you need.
# set the attribute I want to use in another task
task :buy_puppy, [:name] do |_, args|
name = args[:name] || 'Rover'
@dog = Dog.new(name)
end
# task I actually want to run
task :walk_dog => :buy_puppy do
@dog.walk
end