To extend a class in a Redmine plugin and add new methods, you need to follow these steps:
In the path plugin/lib/client I created the file client.rb
#encoding: UTF-8
module RepositoriesPatch
require_dependency 'repositories_controller'
def self.included(base)
base.send(:include, InstanceMethods)
end
end
module InstanceMethods
require_dependency 'repositories_controller'
def exec_client
[....]
end
end
Rails.configuration.to_prepare do
RepositoriesController.send(:include, RepositoriesPatch)
end
Above I created a patch which a new function to repositores_controller and have inserted it using the command .send
In init.rb I put:
Rails.configuration.to_prepare do
RepositoriesController.send(:include, RepositoriesPatch)
end
The rest stood the same. Hope this can be useful to someone. Thanks!