Sha256: 13277e7f75dcf21947da09f74ffd72a0996eeb3e6ddbd2e65da917e57577d2c8

Contents?: true

Size: 1.38 KB

Versions: 5

Compression:

Stored size: 1.38 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 memoizable 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

          # 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

5 entries across 5 versions & 1 rubygems

Version Path
mutant-0.8.7 lib/mutant/subject/method/instance.rb
mutant-0.8.6 lib/mutant/subject/method/instance.rb
mutant-0.8.5 lib/mutant/subject/method/instance.rb
mutant-0.8.4 lib/mutant/subject/method/instance.rb
mutant-0.8.3 lib/mutant/subject/method/instance.rb