Sha256: cebb90c0c3f66c47c0e73dcad6a8094a245c309810a4de9a4f6f4096d09c2ba1

Contents?: true

Size: 1.44 KB

Versions: 6

Compression:

Stored size: 1.44 KB

Contents

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?
          emit_name(:"#{UNDERSCORE}#{name}")
        end

        # Test if argument mutation is skipped
        #
        # @return [Boolean]
        #
        # @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

6 entries across 6 versions & 1 rubygems

Version Path
mutant-0.8.8 lib/mutant/mutator/node/argument.rb
mutant-0.8.7 lib/mutant/mutator/node/argument.rb
mutant-0.8.6 lib/mutant/mutator/node/argument.rb
mutant-0.8.5 lib/mutant/mutator/node/argument.rb
mutant-0.8.4 lib/mutant/mutator/node/argument.rb
mutant-0.8.3 lib/mutant/mutator/node/argument.rb