Project

General

Profile

Patching one method several plugins

Added by Sergey Svoevolin about 10 years ago

Hello.
Used in redmine plugin easyredmine. Plugin modifies several methods in model mail_handler, but we want to make your own plugin that modifies the same methods in the model mail_handler. What problems arise? And how it can be bypassed?


Replies (4)

RE: Patching one method several plugins - Added by Ondřej Moravčík about 10 years ago

Methods can be changed by the same way.

You have to pay attention to the load order. You must ensure that your plugin will be loaded after easyredmine.

RE: Patching one method several plugins - Added by Ondřej Moravčík about 10 years ago

No. It is very old and not for redmine. Look at easyredmine code.

RE: Patching one method several plugins - Added by Sergey Svoevolin about 10 years ago

Do I understand correctly that these actions must be done here?

easyredmine/config/initializers/22-change_plugins_order.rb

In a function named "load"?

def self.load
Dir.glob(File.join(self.directory, '*')).sort_by{|p| (p.ends_with?('/easyproject') ? '0-' : '1-') + p}.each do |directory|
if File.directory?(directory)
lib = File.join(directory, "lib")
if File.directory?(lib)
$:.unshift lib
ActiveSupport::Dependencies.autoload_paths += [lib]
end
initializer = File.join(directory, "init.rb")
if File.file?(initializer)
require initializer
end
end
end
end

    (1-4/4)