Difference between add_class_method and add_to_class server plugin api methods

There are two server side plugin api methods namely, add_to_class and add_class_method. The names are confusing and it seems that these methods can be used interchangeably but that’s not the case.

add_class_method : This method will add a method to the class ( and not the instance) i.e. a static method which can be called like this. (Class.method_name)

add_to_class : This method will add a method to the instance i.e. method which can be called like this. (Class.new.method_name or object.method_name)

2 Likes