Sha256: 0e5d06ee676416b01c873baff1abedde397d69571c907a851619663400ed0a6f
Contents?: true
Size: 952 Bytes
Versions: 36
Compression:
Stored size: 952 Bytes
Contents
# frozen_string_literal: true module Mutant # Registry for mapping AST types to classes class Registry include Concord.new(:contents) # Initialize object # # @return [undefined] def initialize super({}) end # Raised when the type is an invalid type RegistryError = Class.new(TypeError) # Register class for AST node class # # @param [Symbol] type # @param [Class] class # # @return [self] 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 # Lookup class for node # # @param [Symbol] type # # @return [Class<Mutator>] def lookup(type) contents.fetch(type, Mutator::Node::Generic) end end # Registry end # Mutant
Version data entries
36 entries across 36 versions & 1 rubygems