Class: Implements::Implementation::Registry Private
- Inherits:
-
Object
- Object
- Implements::Implementation::Registry
- Defined in:
- lib/implements/implementation/registry.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
A registry of implementations, held by an interface.
Defined Under Namespace
Instance Attribute Summary collapse
- #interface ⇒ Object readonly private
Instance Method Summary collapse
-
#elements(selectors) ⇒ Enumerator<Element>
private
Returns an enumerator of elements matching the given selectors, in the order specified; this is used by Finder#find.
-
#initialize(interface) ⇒ Registry
constructor
private
A new instance of Registry.
- #list_names ⇒ Array<String> private
- #register(implementation, options, check) ⇒ Object private
Constructor Details
#initialize(interface) ⇒ Registry
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Registry.
12 13 14 15 |
# File 'lib/implements/implementation/registry.rb', line 12 def initialize(interface) @interface = interface @elements = [] end |
Instance Attribute Details
#interface ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
16 17 18 |
# File 'lib/implements/implementation/registry.rb', line 16 def interface @interface end |
Instance Method Details
#elements(selectors) ⇒ Enumerator<Element>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns an enumerator of elements matching the given selectors, in the order specified; this is used by Implements::Implementation::Registry::Finder#find.
22 23 24 25 26 27 28 29 30 |
# File 'lib/implements/implementation/registry.rb', line 22 def elements(selectors) Enumerator.new do |yielder| yielded = Set.new Array(selectors).product(@elements) do |selector, element| next unless element.match?(selector) yielder << element if yielded.add?(element) end end end |
#list_names ⇒ Array<String>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
34 35 36 |
# File 'lib/implements/implementation/registry.rb', line 34 def list_names @elements.map(&:name).compact end |
#register(implementation, options, check) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
42 43 44 |
# File 'lib/implements/implementation/registry.rb', line 42 def register(implementation, , check) @elements.unshift Element.new(self, implementation, , check) end |