Sha256: e1956722c7b48fceb3ff72084fa60d72dac64ab6e73706693f1d139f2add39b3

Contents?: true

Size: 1.45 KB

Versions: 18

Compression:

Stored size: 1.45 KB

Contents

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.define_singleton_subclass('ALL', self) do

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

      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
mutant-0.2.20 lib/mutant/mutation/filter.rb
mutant-0.2.17 lib/mutant/mutation/filter.rb
mutant-0.2.16 lib/mutant/mutation/filter.rb
mutant-0.2.15 lib/mutant/mutation/filter.rb
mutant-0.2.14 lib/mutant/mutation/filter.rb
mutant-0.2.13 lib/mutant/mutation/filter.rb
mutant-0.2.12 lib/mutant/mutation/filter.rb
mutant-0.2.11 lib/mutant/mutation/filter.rb
mutant-0.2.9 lib/mutant/mutation/filter.rb
mutant-0.2.8 lib/mutant/mutation/filter.rb
mutant-0.2.7 lib/mutant/mutation/filter.rb
mutant-0.2.6 lib/mutant/mutation/filter.rb
mutant-0.2.5 lib/mutant/mutation/filter.rb
mutant-0.2.4 lib/mutant/mutation/filter.rb
mutant-0.2.3 lib/mutant/mutation/filter.rb
mutant-0.2.2 lib/mutant/mutation/filter.rb
mutant-0.2.1 lib/mutant/mutation/filter.rb
mutant-0.2.0 lib/mutant/mutation/filter.rb