Core plugins wherein a fork of a merged plugin was being used

To a certain degree you can replace/extend logic in existing classes. This might be an option to extend the bundled plugin. You would write a new plugin which just add the modified logic. Using module prepend.

enabled_site_setting :myoverridingplugin_enabled

module ::MyOverridingPlugin
	PLUGIN_NAME = "my-overriding-plugin"

	class Engine < ::Rails::Engine
		engine_name MyOverridingPlugin::PLUGIN_NAME
		isolate_namespace MyOverridingPlugin
	end

	module SomeClassOverrides
		def overriding_method(foo, bar)
			if foo == "something"
				# do something custom
			else
				# this will call the original logic
				super(f00, bar)
			end
		end
	end
end

after_initialize do
	SomeClass.prepend(MyOverridingPlugin::SomeClassOverrides)
end

I used this constructor to limit some controllers under certain conditions.

1 like