Class: Implements::Implementation::Registry::Element Private

Inherits:
Object
  • Object
show all
Defined in:
lib/implements/implementation/registry/element.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.

An Element in a Registry

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(registry, implementation, options, check) ⇒ 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 a new instance of Element.

Parameters:



12
13
14
15
16
17
# File 'lib/implements/implementation/registry/element.rb', line 12

def initialize(registry, implementation, options, check)
  @registry = registry
  @implementation = implementation
  @options = options
  @check = check
end

Instance Attribute Details

#implementationObject (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.



18
19
20
# File 'lib/implements/implementation/registry/element.rb', line 18

def implementation
  @implementation
end

Instance Method Details

#check?(*args) ⇒ Boolean

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.

Check the implementation agains the args that would be used to instantiate it.

Returns:

  • (Boolean)


34
35
36
37
# File 'lib/implements/implementation/registry/element.rb', line 34

def check?(*args)
  return true unless @check
  @check.call(*args)
end

#match?(selector) ⇒ Boolean

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.

Parameters:

  • selector (#===)

Returns:

  • (Boolean)


23
24
25
26
27
# File 'lib/implements/implementation/registry/element.rb', line 23

def match?(selector)
  selector = selector.to_s if selector.kind_of?(Symbol)
  selector = selector.dasherize if selector.kind_of?(String)
  groups.map(&:to_s).any? { |group| selector === group }
end

#nameString

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:

  • (String)


41
42
43
# File 'lib/implements/implementation/registry/element.rb', line 41

def name
  groups.first
end