Sha256: c6ee4cfce228663ee71b87780dfd19574a7269282bbffdd3046dfc35d6e6929e

Contents?: true

Size: 1.54 KB

Versions: 22

Compression:

Stored size: 1.54 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?
          Mutator::Util::Symbol.each(name, self) do |name|
            emit_name(name)
          end
        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

22 entries across 22 versions & 1 rubygems

Version Path
mutant-0.8.0 lib/mutant/mutator/node/argument.rb
mutant-0.7.9 lib/mutant/mutator/node/argument.rb
mutant-0.7.8 lib/mutant/mutator/node/argument.rb
mutant-0.7.7 lib/mutant/mutator/node/argument.rb
mutant-0.7.6 lib/mutant/mutator/node/argument.rb
mutant-0.7.5 lib/mutant/mutator/node/argument.rb
mutant-0.7.4 lib/mutant/mutator/node/argument.rb
mutant-0.7.3 lib/mutant/mutator/node/argument.rb
mutant-0.7.2 lib/mutant/mutator/node/argument.rb
mutant-0.7.1 lib/mutant/mutator/node/argument.rb
mutant-0.6.7 lib/mutant/mutator/node/argument.rb
mutant-0.6.6 lib/mutant/mutator/node/argument.rb
mutant-0.6.5 lib/mutant/mutator/node/argument.rb
mutant-0.6.4 lib/mutant/mutator/node/argument.rb
mutant-0.6.3 lib/mutant/mutator/node/argument.rb
mutant-0.6.2 lib/mutant/mutator/node/argument.rb
mutant-0.6.0 lib/mutant/mutator/node/argument.rb
mutant-0.5.26 lib/mutant/mutator/node/argument.rb
mutant-0.5.25 lib/mutant/mutator/node/argument.rb
mutant-0.5.24 lib/mutant/mutator/node/argument.rb