These are methods I learned of when I was learning Ruby and I never understood why they exist or where they'd be used. Regardless, they exist and I finally found out a use case this weekend.
Send: Invokes the method identified by symbol, passing it any arguments specified. You can use send if the name send clashes with an existing method in obj. When the method is identified by a string, the string is converted to a symbol.
Public Send : Invokes the method identified by symbol, passing it any arguments specified. Unlike send, public_send calls public methods only. When the method is identified by a string, the string is converted to a symbol.
I was building a helper in rails for forms to auto-generate the input tags for specific model fields, so I'd define an array like this
cols = ["first_name", :user, :first_name, "text"]
Where we have the tag's name, the model, the field, and the tag type in that order. This array is then sent to the view where the tags are built based on the contents of the array.
This was done to access the model in such a way that I do not have to hard code it for specific models(as is the case of associated models and such). I was using public send like this
This will call only the public method named in cols of the model named in cols.
I can't think of another use case for public_send and send, so if you're a ruby veteran, please let me know down below if you have used it before.