Class: Mikutter::PluginBase
- Inherits:
-
Object
- Object
- Mikutter::PluginBase
- Defined in:
- lib/mikutter_plugin_base.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.register! ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/mikutter_plugin_base.rb', line 8 def register! instance = new procedure = lambda do |plugin| instance.method(:run).to_proc.call( instance.method(:add_events).to_proc.call(plugin) ) end ::Plugin.create to_plugin_name(self.class.to_s), &procedure end |
.to_plugin_name(class_name) ⇒ Object
18 19 20 |
# File 'lib/mikutter_plugin_base.rb', line 18 def to_plugin_name(class_name) class_name.underscore.to_sym end |
Instance Method Details
#add_events(plugin) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/mikutter_plugin_base.rb', line 23 def add_events(plugin) methods.each do |name| case name.to_s when /^on_?(.+)$/ plugin.add_event $1, &method(name).to_proc when /^filter_?(.+)$/ plugin.add_event_filter $1, &method(name).to_proc when /^hook_?(.+)$/ plugin.add_event_hook $1, &method(name).to_proc end end plugin end |
#run(plugin) ⇒ Object
37 38 39 |
# File 'lib/mikutter_plugin_base.rb', line 37 def run(plugin) raise NotImplementedError end |