Implement a plugin system.
Each plugin have to inherite from this class and implement a can_handle?(site) method.
Return the plugin that can handle a given site.
# File lib/site_plugin.rb, line 16 def self.for_site(site) @@repository.find { |handler| handler.can_handle? site } end
# File lib/site_plugin.rb, line 11 def self.inherited(target) @@repository << target end
# File lib/site_plugin.rb, line 7 def self.repository @@repository end
Raise an error message if the missing method should have been implemented in the subclasse. This possible methode are:
#can_handle?
#get
They *must* be implemented by the subclasse.
# File lib/site_plugin.rb, line 26 def method_missing(method) return unless ['can_handle?', 'get'].include(method) raise "Method #{method} not implemented !" end