Module: Xavier::MutationStrategies::ClassCopy Private

Defined in:
lib/xavier/mutation_strategies/class_copy.rb

Overview

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

Copies the class variables from one object to other.

Class Method Summary collapse

Class Method Details

.copy(from:, to:) ⇒ Array<String>

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.

Copies the class variables from one object to other.

Parameters:

  • from

    An object where the state will be copied from.

  • to

    An object where the state will be copied to.

Returns:

  • (Array<String>)

    A list of variable names that were copied.



15
16
17
18
# File 'lib/xavier/mutation_strategies/class_copy.rb', line 15

def self.copy(from:, to:)
  vars = from.class_variables.map(&:to_s)
  vars.each { |name| to.class_variable_set(name, from.class_variable_get(name)) }
end