class SitePlugin

Implement a plugin system.

Each plugin have to inherite from this class and implement a can_handle?(site) method.

Public Class Methods

for_site(site) click to toggle source

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
inherited(target) click to toggle source
# File lib/site_plugin.rb, line 11
def self.inherited(target)
    @@repository << target
end
repository() click to toggle source
# File lib/site_plugin.rb, line 7
def self.repository
    @@repository
end

Public Instance Methods

method_missing(method) click to toggle source

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