Sha256: aef613fa4958041fc4547f0f6b834a4cb6ac3b6f1e8f7f7612b03ccdc7286850

Contents?: true

Size: 1.05 KB

Versions: 6

Compression:

Stored size: 1.05 KB

Contents

module Mutant
  class Subject
    class Method
      # Instance method subjects
      class Instance < self

        NAME_INDEX = 0
        SYMBOL     = '#'.freeze

        # Prepare subject for mutation insertion
        #
        # @return [self]
        def prepare
          scope.__send__(:undef_method, name)
          self
        end

        # Mutator for memoizable memoized instance methods
        class Memoized < self
          include AST::Sexp

          # Prepare subject for mutation insertion
          #
          # @return [self]
          def prepare
            scope.__send__(:memoized_methods).instance_variable_get(:@memory).delete(name)
            super()
          end

        private

          # Memoizer node for mutant
          #
          # @param [Parser::AST::Node] mutant
          #
          # @return [Parser::AST::Node]
          def wrap_node(mutant)
            s(:begin, mutant, s(:send, nil, :memoize, s(:args, s(:sym, name))))
          end

        end # Memoized
      end # Instance
    end # Method
  end # Subject
end # Mutant

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
mutant-0.8.16 lib/mutant/subject/method/instance.rb
mutant-0.8.15 lib/mutant/subject/method/instance.rb
mutant-0.8.14 lib/mutant/subject/method/instance.rb
mutant-0.8.13 lib/mutant/subject/method/instance.rb
mutant-0.8.12 lib/mutant/subject/method/instance.rb
mutant-0.8.11 lib/mutant/subject/method/instance.rb