Class: Mutant::Registry Private
- Inherits:
-
Object
- Object
- Mutant::Registry
- Defined in:
- lib/mutant/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.
Registry for mapping AST types to classes
Defined Under Namespace
Classes: RegistryError
Instance Method Summary collapse
-
#initialize(default) ⇒ undefined
constructor
private
Initialize object.
-
#lookup(type) ⇒ Class<Mutator>
private
Lookup class for node.
-
#register(type, klass) ⇒ self
private
Register class for AST node class.
Constructor Details
#initialize(default) ⇒ undefined
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.
Initialize object
11 12 13 |
# File 'lib/mutant/registry.rb', line 11 def initialize(default) super(contents: {}, default:) end |
Instance Method Details
#lookup(type) ⇒ Class<Mutator>
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.
Lookup class for node
37 38 39 |
# File 'lib/mutant/registry.rb', line 37 def lookup(type) contents.fetch(type, &default) end |
#register(type, klass) ⇒ self
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.
Register class for AST node class
25 26 27 28 29 30 |
# File 'lib/mutant/registry.rb', line 25 def register(type, klass) fail RegistryError, "Invalid type registration: #{type.inspect}" unless AST::Types::ALL.include?(type) fail RegistryError, "Duplicate type registration: #{type.inspect}" if contents.key?(type) contents[type] = klass self end |