Sha256: d19f3f377aa97e6f81f25f3d54182ae19588e2d34575eadc625194f71bd340ce

Contents?: true

Size: 1.11 KB

Versions: 20

Compression:

Stored size: 1.11 KB

Contents

module Mutant
  class Mutator
    # Registry for mutators
    module Registry
      # Return registry state
      #
      # @return [Hash]
      #
      # @api private
      #
      def self.registry
        @registry ||= {}
      end
      private_class_method :registry

      # Register mutator class for AST node class
      #
      # @param [Symbol] type
      # @param [Class] mutator_class
      #
      # @api private
      #
      # @return [self]
      #
      def self.register(type, mutator_class)
        raise "duplicate type registration: #{type}" if registry.key?(type)
        registry[type]=mutator_class
        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 self.lookup(node)
        type = node.type
        registry.fetch(type) do
          raise ArgumentError,"No mutator to handle: #{type.inspect}"
        end
      end

    end # Registry
  end # Mutator
end # Mutant

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
mutant-0.3.0.beta21 lib/mutant/mutator/registry.rb
mutant-0.3.0.beta20 lib/mutant/mutator/registry.rb
mutant-0.3.0.beta19 lib/mutant/mutator/registry.rb
mutant-0.3.0.beta18 lib/mutant/mutator/registry.rb
mutant-0.3.0.beta17 lib/mutant/mutator/registry.rb
mutant-0.3.0.beta16 lib/mutant/mutator/registry.rb
mutant-0.3.0.beta15 lib/mutant/mutator/registry.rb
mutant-0.3.0.beta14 lib/mutant/mutator/registry.rb
mutant-0.3.0.beta13 lib/mutant/mutator/registry.rb
mutant-0.3.0.beta12 lib/mutant/mutator/registry.rb
mutant-0.3.0.beta11 lib/mutant/mutator/registry.rb
mutant-0.3.0.beta10 lib/mutant/mutator/registry.rb
mutant-0.3.0.beta9 lib/mutant/mutator/registry.rb
mutant-0.3.0.beta8 lib/mutant/mutator/registry.rb
mutant-0.3.0.beta7 lib/mutant/mutator/registry.rb
mutant-0.3.0.beta6 lib/mutant/mutator/registry.rb
mutant-0.3.0.beta5 lib/mutant/mutator/registry.rb
mutant-0.3.0.beta4 lib/mutant/mutator/registry.rb
mutant-0.3.0.beta3 lib/mutant/mutator/registry.rb
mutant-0.3.0.beta2 lib/mutant/mutator/registry.rb