Class: RailsErrorDashboard::PluginRegistry
- Inherits:
-
Object
- Object
- RailsErrorDashboard::PluginRegistry
- Defined in:
- lib/rails_error_dashboard/plugin_registry.rb
Overview
Registry for managing plugins Provides plugin registration and event dispatching
Class Method Summary collapse
-
.any? ⇒ Boolean
Check if any plugins are registered.
-
.clear ⇒ Object
Clear all plugins (useful for testing).
-
.count ⇒ Object
Get count of registered plugins.
-
.dispatch(event_name, *args) ⇒ Object
Dispatch an event to all registered plugins.
-
.find(plugin_name) ⇒ Plugin?
Get a plugin by name.
-
.info ⇒ Object
Get plugin information for debugging.
-
.names ⇒ Object
Get list of plugin names.
-
.plugins ⇒ Object
Get all registered plugins.
-
.register(plugin) ⇒ Object
Register a plugin.
-
.unregister(plugin_name) ⇒ Object
Unregister a plugin by name.
Class Method Details
.any? ⇒ Boolean
Check if any plugins are registered
66 67 68 |
# File 'lib/rails_error_dashboard/plugin_registry.rb', line 66 def any? plugins.any? end |
.clear ⇒ Object
Clear all plugins (useful for testing)
38 39 40 |
# File 'lib/rails_error_dashboard/plugin_registry.rb', line 38 def clear @plugins = [] end |
.count ⇒ Object
Get count of registered plugins
61 62 63 |
# File 'lib/rails_error_dashboard/plugin_registry.rb', line 61 def count plugins.size end |
.dispatch(event_name, *args) ⇒ Object
Dispatch an event to all registered plugins
52 53 54 55 56 57 58 |
# File 'lib/rails_error_dashboard/plugin_registry.rb', line 52 def dispatch(event_name, *args) plugins.each do |plugin| next unless plugin.enabled? plugin.safe_execute(event_name, *args) end end |
.find(plugin_name) ⇒ Plugin?
Get a plugin by name
45 46 47 |
# File 'lib/rails_error_dashboard/plugin_registry.rb', line 45 def find(plugin_name) plugins.find { |p| p.name == plugin_name } end |
.info ⇒ Object
Get plugin information for debugging
76 77 78 79 80 81 82 83 84 85 |
# File 'lib/rails_error_dashboard/plugin_registry.rb', line 76 def info plugins.map do |plugin| { name: plugin.name, version: plugin.version, description: plugin.description, enabled: plugin.enabled? } end end |
.names ⇒ Object
Get list of plugin names
71 72 73 |
# File 'lib/rails_error_dashboard/plugin_registry.rb', line 71 def names plugins.map(&:name) end |
.plugins ⇒ Object
Get all registered plugins
9 10 11 |
# File 'lib/rails_error_dashboard/plugin_registry.rb', line 9 def plugins @plugins ||= [] end |
.register(plugin) ⇒ Object
Register a plugin
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/rails_error_dashboard/plugin_registry.rb', line 15 def register(plugin) unless plugin.is_a?(Plugin) raise ArgumentError, "Plugin must be an instance of RailsErrorDashboard::Plugin" end if plugins.any? { |p| p.name == plugin.name } RailsErrorDashboard::Logger.warn("Plugin '#{plugin.name}' is already registered, skipping") return false end plugins << plugin plugin.on_register RailsErrorDashboard::Logger.info("Registered plugin: #{plugin.name} (#{plugin.version})") true end |
.unregister(plugin_name) ⇒ Object
Unregister a plugin by name
33 34 35 |
# File 'lib/rails_error_dashboard/plugin_registry.rb', line 33 def unregister(plugin_name) plugins.reject! { |p| p.name == plugin_name } end |