How do I pass a function-like object as argument to a PeriodicCallback in DifferentialEquations?

[EDIT: I can no longer recreate my original error and can confirm that function-like objects can be used as callback functions to pass to solve in DifferentialEquations.jl.]

If I create a struct and a function-like object (as described in https://pkg.julialang.org/docs/julia/THl1k/1.1.1/manual/methods.html#Function-like-objects-1), how can I get a handle on the function as opposed to the object itself? I want to pass one as a function to PeriodicCallback in solve (using DifferentialEquations), but I get a MethodError: objects of type Controller are not callable (Controller is a struct I’ve defined).

If I create a named function rather than using the function-like object technique, it works as expected.

Does calling your object work in the REPL?

Hmm, I’m going to say yes, as I cannot now recreate my original issue.

I had worked around my issue by creating a normal named function of signature

function fctrl (controller, integrator)
   # some control stuff here
end

and then making an instance of my Controller and using function composition to get a function with a single argument acceptable as a callback.

controller = Controller( ... )
f(integrator) = fctrl(controller, integrator)

and passing f as the callback worked.

This morning I went back to the function-like object construction to recreate the error, so now things look like

controller = Controller( ... )
function (c::Controller)(integrator)
   # some control stuff here
end

and just passing controller as the callback function is now working. At this point I have to assume I did something else wrong in my previous construction of the function-like object that led to the errors I was getting.