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

Inherits:
Object
  • Object
show all
Includes:
Support::RecursiveConstMethods
Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/lib/rspec/mocks/mutate_const.rb

Overview

Contains common functionality used by all of the constant mutators.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Support::RecursiveConstMethods

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

Constructor Details

#initialize(full_constant_name, mutated_value, transfer_nested_constants) ⇒ BaseMutator

Returns a new instance of BaseMutator.



144
145
146
147
148
149
150
151
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/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_nameObject (readonly)

Returns the value of attribute full_constant_name.



142
143
144
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/lib/rspec/mocks/mutate_const.rb', line 142

def full_constant_name
  @full_constant_name
end

#original_valueObject (readonly)

Returns the value of attribute original_value.



142
143
144
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/lib/rspec/mocks/mutate_const.rb', line 142

def original_value
  @original_value
end

Instance Method Details

#idempotently_resetObject



160
161
162
163
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/lib/rspec/mocks/mutate_const.rb', line 160

def idempotently_reset
  reset unless @reset_performed
  @reset_performed = true
end

#to_constantObject



153
154
155
156
157
158
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/lib/rspec/mocks/mutate_const.rb', line 153

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

  const
end