Sha256: 4b36cc77c638035ea60053b5f161fa79200ae47bcf9a39afc2f093c7b6938e9a

Contents?: true

Size: 1.48 KB

Versions: 20

Compression:

Stored size: 1.48 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.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

20 entries across 20 versions & 1 rubygems

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