Rewriting method from a plugin - "Self" context

Hello,

I’m trying to modify upload instructions from a plugin.

Can I use add_to_class to rewrite a class method that is in “self” context?

e.g. to take original method in OptimizedImage class

def self.resize_instructions(from, to, dimensions, opts = {})

and overwrite it in plugin with something like
add_to_class(:OptimizedImage, :self.resize_instructions) do |from, to, dimensions, opts|

This is obviously not that straightforward :slight_smile:
Thanks!

You would use add_class_method

7 Likes