Sha256: 51d0882026a641b12761723e6d83fb13fde567691c66e4355498dc39df7bff2e
Contents?: true
Size: 1.29 KB
Versions: 11
Compression:
Stored size: 1.29 KB
Contents
module Mutant class Mutator # Registry for mutators class Registry # Initialize object # # @return [undefined] # # @api private # def initialize @registry = {} end # Raised when the type is an invalid type RegistryError = Class.new(TypeError) # Register mutator class for AST node class # # @param [Symbol] type # @param [Class:Mutator] mutator # # @api private # # @return [self] # def register(type, mutator) fail RegistryError, "Invalid type registration: #{type}" unless AST::Types::ALL.include?(type) fail RegistryError, "Duplicate type registration: #{type}" if @registry.key?(type) @registry[type] = mutator self end # Lookup mutator class for node # # @param [Parser::AST::Node] node # # @return [Class] # # @raise [ArgumentError] # raises argument error when mutator class cannot be found # # @api private # def lookup(node) type = node.type @registry.fetch(type) do fail RegistryError, "No mutator to handle: #{type.inspect}" end end end # Registry REGISTRY = Registry.new end # Mutator end # Mutant
Version data entries
11 entries across 11 versions & 1 rubygems