Sha256: 6db971d38338b59d8bf29494823134b583a2c2f1c246d6110d8ca7d58676b5ab

Contents?: true

Size: 1.42 KB

Versions: 9

Compression:

Stored size: 1.42 KB

Contents

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

        NAME_INDEX = 0
        SYMBOL     = '#'.freeze

        # Test if method is public
        #
        # @return [Boolean]
        #
        # @api private
        #
        def public?
          scope.public_method_defined?(name)
        end
        memoize :public?

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

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

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

        private

          # Return memoizer node for mutant
          #
          # @param [Parser::AST::Node] mutant
          #
          # @return [Parser::AST::Node]
          #
          # @api private
          #
          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

9 entries across 9 versions & 1 rubygems

Version Path
mutant-0.8.0 lib/mutant/subject/method/instance.rb
mutant-0.7.9 lib/mutant/subject/method/instance.rb
mutant-0.7.8 lib/mutant/subject/method/instance.rb
mutant-0.7.7 lib/mutant/subject/method/instance.rb
mutant-0.7.6 lib/mutant/subject/method/instance.rb
mutant-0.7.5 lib/mutant/subject/method/instance.rb
mutant-0.7.4 lib/mutant/subject/method/instance.rb
mutant-0.7.3 lib/mutant/subject/method/instance.rb
mutant-0.7.2 lib/mutant/subject/method/instance.rb