Skip to content

Instantly share code, notes, and snippets.

@radar
Created December 28, 2010 01:56
Show Gist options
  • Save radar/756790 to your computer and use it in GitHub Desktop.
Save radar/756790 to your computer and use it in GitHub Desktop.
def self.factory(plugin, &block)
candidates = self.plugin_paths.map do |path|
Dir["#{path}/#{plugin.to_s.downcase}.rb"][0]
end
candidate = candidates.detect(&:any?)
if candidate
require candidate
Plugin.const_get(plugin.to_s.capitalize.to_sym).new(&block)
else
raise YourSystem::PluginNotFound, "The #{plugin} plugin could not be loaded"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment