Sha256: 79bd3034cad56c02786d4e8b16d620d9e183d421f8944863b34fdacbe8b2b412
Contents?: true
Size: 1.33 KB
Versions: 10
Compression:
Stored size: 1.33 KB
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) # * avatar - called to get an avatar url from an email md5 sum # run arguments (avatar url, url, config hash) # * store_asset - store an asset somewhere where it can be loaded by url # run arguments (name, data, config hash) # * url_display_add - called to display additional information after urls # run arguments (markup builder, url, config hash) # * url_display_pre - called to modify a url on-the-fly before display, does # not change database # run arguments (url, rack request, config hash) 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.find_all { |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 :hook attr_reader :registered end end end
Version data entries
10 entries across 10 versions & 1 rubygems