I have many different classes under /lib/ folder with many actions.
Before saving an object I need to call a method from a class that matches its name with an attribute inside the object i.e. given this
User.gateway = "something"
I need to call myfunction from something class before the object is saved.
Not sure how to do this.
your question is quite ambiguous,is this what you need?