I'm not sure if I've understood the concept of notifying other resources based on a custom resource correctly. I have a resource:
get_api_calls 'www.myapi.com' do
request '<myrequest>'
target_path '/<my>/<target>/<filepath>
notifies :reload, 'service[apache]', :delayed
end
This demo resource is ficitonal but shows what I want to do. Under the hood it queries the API, downloads the necessary file and stores it into my_target_filepath. Everytime I execute the Chef code from above, it reloads Apache. That makes sense because I'm telling the DSL to reload the resource everytime it's executed. But I don't want this behavior. I want to norify to reload Apache if a file has been downloaded and updated from the API only.
I mean the file resource acts the same in the end. It updates or creates a file under the hood and notifies only another resource instead of notifying it everytime it gets executed without changing something.
How is it possible to implement that behavior for my resource?
I've used Ruby blocks for the whole API interaction. Removing the blocks and run_context from file ressource solved the issue.