123456789_123456789_123456789_123456789_123456789_

Class: RSpec::Mocks::ConstantMutator::BaseMutator Private

Relationships & Source Files
Extension / Inclusion / Inheritance Descendants
Subclasses:
Super Chains via Extension / Inclusion / Inheritance
Instance Chain:
Inherits: Object
Defined in: rspec-mocks/lib/rspec/mocks/mutate_const.rb

Overview

Contains common functionality used by all of the constant mutators.

Class Method Summary

Instance Attribute Summary

Instance Method Summary

::RSpec::Support::RecursiveConstMethods - Included

#const_defined_on?

See additional method definition at line 31.

#constants_defined_on

See additional method definition at line 41.

#get_const_defined_on

See additional method definition at line 35.

#normalize_const_name, #recursive_const_defined?, #recursive_const_get

Constructor Details

.new(full_constant_name, mutated_value, transfer_nested_constants) ⇒ BaseMutator

[ GitHub ]

  
# File 'rspec-mocks/lib/rspec/mocks/mutate_const.rb', line 144

def initialize(full_constant_name, mutated_value, transfer_nested_constants)
  @full_constant_name        = normalize_const_name(full_constant_name)
  @mutated_value             = mutated_value
  @transfer_nested_constants = transfer_nested_constants
  @context_parts             = @full_constant_name.split('::')
  @const_name                = @context_parts.pop
  @reset_performed           = false
end

Instance Attribute Details

#full_constant_name (readonly)

[ GitHub ]

  
# File 'rspec-mocks/lib/rspec/mocks/mutate_const.rb', line 142

attr_reader :original_value, :full_constant_name

#original_value (readonly)

[ GitHub ]

  
# File 'rspec-mocks/lib/rspec/mocks/mutate_const.rb', line 142

attr_reader :original_value, :full_constant_name

Instance Method Details

#idempotently_reset

[ GitHub ]

  
# File 'rspec-mocks/lib/rspec/mocks/mutate_const.rb', line 160

def idempotently_reset
  reset unless @reset_performed
  @reset_performed = true
end

#to_constant

[ GitHub ]

  
# File 'rspec-mocks/lib/rspec/mocks/mutate_const.rb', line 153

def to_constant
  const = Constant.new(full_constant_name)
  const.original_value = original_value

  const
end