Module: Flows::Util::InheritableSingletonVars::DupStrategy::Migrator Private

Defined in:
lib/flows/util/inheritable_singleton_vars/dup_strategy.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.

Since:

  • 0.4.0

Class Method Summary collapse

Class Method Details

.call(src_mod, dst_mod) ⇒ Object

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.

:reek:TooManyStatements is allowed here because it's impossible to split to smaller methods

Since:

  • 0.4.0



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/flows/util/inheritable_singleton_vars/dup_strategy.rb', line 28

def self.call(src_mod, dst_mod)
  parent_var_list = src_mod.instance_variable_get(VAR_LIST_VAR_NAME)
  child_var_list = dst_mod.instance_variable_get(VAR_LIST_VAR_NAME) || []
  skip_list = parent_var_list & child_var_list

  dst_mod.instance_variable_set(VAR_LIST_VAR_NAME, (child_var_list + parent_var_list).uniq)

  (parent_var_list - skip_list).each do |name|
    dst_mod.instance_variable_set(name, src_mod.instance_variable_get(name).dup)
  end
end