Class: Rigor::Plugin::ContributionIndex
- Inherits:
-
Object
- Object
- Rigor::Plugin::ContributionIndex
- Defined in:
- lib/rigor/plugin/registry.rb
Overview
Categorises a loaded plugin set by which per-call contribution paths each plugin actually implements, so the engine’s per-dispatch ‘collect_plugin_contributions` can iterate only the relevant plugins instead of calling into every plugin on every call site (a top hotspot on plugin-heavy projects — GitLab’s 11 plugins, of which only 2 implement any per-call path). Built once per Registry; the receiver-class ancestry match for ‘dynamic_return` still happens per-dispatch inside `Plugin::Base#dynamic_return_type`, so this only prunes plugins that structurally cannot contribute, preserving the exact contribution order and result.
Instance Attribute Summary collapse
-
#for_method_dispatch ⇒ Object
readonly
Ordered (registry-order) subsets relevant to each collector, and the membership sets used to gate the two paths within a plugin.
-
#for_statement ⇒ Object
readonly
Ordered (registry-order) subsets relevant to each collector, and the membership sets used to gate the two paths within a plugin.
Instance Method Summary collapse
- #dynamic?(plugin) ⇒ Boolean
- #flow?(plugin) ⇒ Boolean
-
#initialize(plugins) ⇒ ContributionIndex
constructor
A new instance of ContributionIndex.
- #type_specifier?(plugin) ⇒ Boolean
Constructor Details
#initialize(plugins) ⇒ ContributionIndex
Returns a new instance of ContributionIndex.
22 23 24 25 26 27 28 29 |
# File 'lib/rigor/plugin/registry.rb', line 22 def initialize(plugins) @flow = plugins.select { |p| flow_overridden?(p) }.to_set @dynamic = plugins.reject { |p| p.class.dynamic_returns.empty? }.to_set @type_specifier = plugins.reject { |p| p.class.type_specifiers.empty? }.to_set @for_method_dispatch = plugins.select { |p| @flow.include?(p) || @dynamic.include?(p) }.freeze @for_statement = plugins.select { |p| @flow.include?(p) || @type_specifier.include?(p) }.freeze freeze end |
Instance Attribute Details
#for_method_dispatch ⇒ Object (readonly)
Ordered (registry-order) subsets relevant to each collector, and the membership sets used to gate the two paths within a plugin.
20 21 22 |
# File 'lib/rigor/plugin/registry.rb', line 20 def for_method_dispatch @for_method_dispatch end |
#for_statement ⇒ Object (readonly)
Ordered (registry-order) subsets relevant to each collector, and the membership sets used to gate the two paths within a plugin.
20 21 22 |
# File 'lib/rigor/plugin/registry.rb', line 20 def for_statement @for_statement end |
Instance Method Details
#dynamic?(plugin) ⇒ Boolean
32 |
# File 'lib/rigor/plugin/registry.rb', line 32 def dynamic?(plugin) = @dynamic.include?(plugin) |
#flow?(plugin) ⇒ Boolean
31 |
# File 'lib/rigor/plugin/registry.rb', line 31 def flow?(plugin) = @flow.include?(plugin) |
#type_specifier?(plugin) ⇒ Boolean
33 |
# File 'lib/rigor/plugin/registry.rb', line 33 def type_specifier?(plugin) = @type_specifier.include?(plugin) |