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

Inherits:
Object
  • Object
show all
Includes:
RecursiveConstMethods
Defined in:
lib/rspec/mocks/mutate_const.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Contains common functionality used by all of the constant mutators.

Direct Known Subclasses

ConstantHider, DefinedConstantReplacer, UndefinedConstantSetter

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Methods included from RecursiveConstMethods

#const_defined_on?, #constants_defined_on, #get_const_defined_on, #normalize_const_name, #recursive_const_defined?, #recursive_const_get

Constructor Details

- (BaseMutator) initialize(full_constant_name, mutated_value, transfer_nested_constants)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

A new instance of BaseMutator

210
211
212
213
214
215
216
# File 'lib/rspec/mocks/mutate_const.rb', line 210
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
end

Instance Attribute Details

- (Object) full_constant_name (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

208
209
210
# File 'lib/rspec/mocks/mutate_const.rb', line 208
def full_constant_name
  @full_constant_name
end

- (Object) original_value (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

208
209
210
# File 'lib/rspec/mocks/mutate_const.rb', line 208
def original_value
  @original_value
end

Instance Method Details

- (Object) to_constant

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

218
219
220
221
222
223
# File 'lib/rspec/mocks/mutate_const.rb', line 218
def to_constant
  const = Constant.new(full_constant_name)
  const.original_value = original_value
  const
end