Sha256: 2525693834ebc2da60e4d4438f044e5ae4812c5ab89f2e560075e491dcbcf332

Contents?: true

Size: 1.66 KB

Versions: 29

Compression:

Stored size: 1.66 KB

Contents

# encoding: utf-8

module Mutant
  class Mutator
    class Node

      # Mutator for required arguments
      class Argument < self
        handle(:arg)

        UNDERSCORE = '_'.freeze

        children :name

      private

        # Perform dispatch
        #
        # @return [undefined]
        #
        # @api private
        #
        def dispatch
          emit_name_mutation
        end

        # Emit name mutations
        #
        # @return [undefined]
        #
        # @api private
        #
        def emit_name_mutation
          return if skip?
          Mutator::Util::Symbol.each(name, self) do |name|
            emit_name(name)
          end
        end

        # Test if argument mutation is skipped
        #
        # @return [true]
        #   if argument should not get mutated
        #
        # @return [false]
        #   otherwise
        #
        # @api private
        #
        def skip?
          name.to_s.start_with?(UNDERSCORE)
        end

        # Mutator for optional arguments
        class Optional < self

          handle(:optarg)

          children :name, :default

        private

          # Perform dispatch
          #
          # @return [undefined]
          #
          # @api private
          #
          def dispatch
            emit_name_mutation
            emit_required_mutation
            emit_default_mutations
          end

          # Emit required mutation
          #
          # @return [undefined]
          #
          # @api private
          #
          def emit_required_mutation
            emit(s(:arg, name))
          end

        end # Optional

      end # Argument
    end # Node
  end # Mutator
end # Mutant

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
mutant-0.5.19 lib/mutant/mutator/node/argument.rb
mutant-0.5.18 lib/mutant/mutator/node/argument.rb
mutant-0.5.17 lib/mutant/mutator/node/argument.rb
mutant-0.5.16 lib/mutant/mutator/node/argument.rb
mutant-0.5.15 lib/mutant/mutator/node/argument.rb
mutant-0.5.14 lib/mutant/mutator/node/argument.rb
mutant-0.5.13 lib/mutant/mutator/node/argument.rb
mutant-0.5.12 lib/mutant/mutator/node/argument.rb
mutant-0.5.11 lib/mutant/mutator/node/argument.rb
mutant-0.5.10 lib/mutant/mutator/node/argument.rb
mutant-0.5.9 lib/mutant/mutator/node/argument.rb
mutant-0.5.8 lib/mutant/mutator/node/argument.rb
mutant-0.5.7 lib/mutant/mutator/node/argument.rb
mutant-0.5.6 lib/mutant/mutator/node/argument.rb
mutant-0.5.5 lib/mutant/mutator/node/argument.rb
mutant-0.5.4 lib/mutant/mutator/node/argument.rb
mutant-0.5.3 lib/mutant/mutator/node/argument.rb
mutant-0.5.2 lib/mutant/mutator/node/argument.rb
mutant-0.5.1 lib/mutant/mutator/node/argument.rb
mutant-0.5.0 lib/mutant/mutator/node/argument.rb