Sha256: 9bfc79b96fc3ff34a1e9bdb4ea9aaee3d78bc29b20022637255b6e12a291c957

Contents?: true

Size: 1.5 KB

Versions: 2

Compression:

Stored size: 1.5 KB

Contents

# encoding: utf-8

module Mutant
  class Mutation
    # Abstract filter for mutations
    class Filter
      include Adamantium::Flat, AbstractType
      extend DescendantsTracker

      # Check for match
      #
      # @param [Mutation] mutation
      #
      # @return [true]
      #   returns true if mutation is matched by filter
      #
      # @return [false]
      #   returns false otherwise
      #
      # @api private
      #
      abstract_method :match?

      # Build filter from string
      #
      # @param [String] notation
      #
      # @return [Filter]
      #   returns filter when can be buld from string
      #
      # @return [nil]
      #   returns nil otherwise
      #
      # @api private
      #
      def self.build(notation)
        descendants.each do |descendant|
          filter = descendant.handle(notation)
          return filter if filter
        end

        nil
      end

      # Return filter for handle
      #
      # @param [String] _notation
      #
      # @return [nil]
      #   returns nil
      #
      # @api private
      #
      def self.handle(_notation)
        nil
      end

      # Mutation filter matching all mutations
      Mutant.singleton_subclass_instance('ALL', self) do

        # Test for match
        #
        # @pram [Mutation] _mutation
        #
        # @return [true]
        #   returns true
        #
        # @api private
        #
        def match?(_mutation)
          true
        end

      end

    end # Filter
  end # Mutation
end # Mutant

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mutant-0.3.0.rc1 lib/mutant/mutation/filter.rb
mutant-0.3.0.beta22 lib/mutant/mutation/filter.rb