Class: Murlsh::Plugin
- Inherits:
-
Object
- Object
- Murlsh::Plugin
- Defined in:
- lib/murlsh/plugin.rb
Overview
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)
-
html_parse - called to parse HTML using something like Hpricot or Nokogiri run arguments (parseable)
-
url_display_add - called to display additional information after urls run arguments (markup builder, url, config hash)
Class Attribute Summary collapse
-
.hook ⇒ Object
readonly
Returns the value of attribute hook.
-
.registered ⇒ Object
readonly
Returns the value of attribute registered.
Class Method Summary collapse
-
.hooks(name) ⇒ Object
Get registered plugins by hook (add_pre, add_post, etc.).
-
.inherited(child) ⇒ Object
Called when a plugin class inherits from this class (the way plugins are registered).
Class Attribute Details
.hook ⇒ Object (readonly)
Returns the value of attribute hook.
37 38 39 |
# File 'lib/murlsh/plugin.rb', line 37 def hook @hook end |
.registered ⇒ Object (readonly)
Returns the value of attribute registered.
38 39 40 |
# File 'lib/murlsh/plugin.rb', line 38 def registered @registered end |
Class Method Details
.hooks(name) ⇒ Object
Get registered plugins by hook (add_pre, add_post, etc.)
25 26 27 28 29 30 31 32 33 |
# File 'lib/murlsh/plugin.rb', line 25 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 |
.inherited(child) ⇒ Object
Called when a plugin class inherits from this class (the way plugins are registered).
20 21 22 |
# File 'lib/murlsh/plugin.rb', line 20 def self.inherited(child) registered << child end |