Sha256: 4fff12f9837a9f8997eebb58f325c00ba8cce6a52630d9fe3d4a996bc107d624
Contents?: true
Size: 911 Bytes
Versions: 7
Compression:
Stored size: 911 Bytes
Contents
module Murlsh # Superclass for plugins. How plugins are registered. # # Hooks: # * add_pre - called before a new url is saved # run arguments (url, config hash) # * add_post - called after a new url is saved # run arguments (config hash) # * hostrec - called to post process the domain that shows after links # run arguments (domain, url, title) class Plugin # Called when a plugin class inherits from this class (the way plugins # are registered). def self.inherited(child) registered << child end # Get registered plugins by hook (add_pre, add_post, etc.) def self.hooks(name) matches = registered.select { |p| p::Hook == name }. sort { |a,b| a.to_s <=> b.to_s } if block_given? matches.each { |p| yield p } end matches end @registered = [] class << self; attr_reader :registered end end end
Version data entries
7 entries across 7 versions & 1 rubygems