Class: BetterAuth::PluginRegistry
- Inherits:
-
Object
- Object
- BetterAuth::PluginRegistry
- Defined in:
- lib/better_auth/plugin_registry.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#plugins ⇒ Object
readonly
Returns the value of attribute plugins.
Instance Method Summary collapse
- #endpoints ⇒ Object
- #error_codes(base) ⇒ Object
-
#initialize(context) ⇒ PluginRegistry
constructor
A new instance of PluginRegistry.
- #run_init! ⇒ Object
Constructor Details
#initialize(context) ⇒ PluginRegistry
Returns a new instance of PluginRegistry.
7 8 9 10 |
# File 'lib/better_auth/plugin_registry.rb', line 7 def initialize(context) @context = context @plugins = context..plugins end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
5 6 7 |
# File 'lib/better_auth/plugin_registry.rb', line 5 def context @context end |
#plugins ⇒ Object (readonly)
Returns the value of attribute plugins.
5 6 7 |
# File 'lib/better_auth/plugin_registry.rb', line 5 def plugins @plugins end |
Instance Method Details
#endpoints ⇒ Object
27 28 29 30 31 |
# File 'lib/better_auth/plugin_registry.rb', line 27 def endpoints plugins.each_with_object({}) do |plugin, result| result.merge!(plugin.endpoints) end end |
#error_codes(base) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/better_auth/plugin_registry.rb', line 33 def error_codes(base) plugins.each_with_object(base.dup) do |plugin, codes| plugin.error_codes.each do |key, value| codes[key.to_s.upcase] = value end end end |
#run_init! ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/better_auth/plugin_registry.rb', line 12 def run_init! plugins.each do |plugin| next unless plugin.init result = plugin.init.call(context) next unless result.is_a?(Hash) (plugin, result[:options] || result["options"]) PluginContext.new(context, plugin).apply!(result[:context] || result["context"]) end context. context.set_internal_adapter(Adapters::InternalAdapter.new(context.adapter, context.)) end |