Module: Kettle::Wash::Change::ConstantChange

Defined in:
lib/kettle/wash.rb,
sig/kettle/wash.rbs

Class Method Summary collapse

Class Method Details

.to_mod(constants:, path:) ⇒ Module

Parameters:

  • constants: (Array[String | Symbol])
  • path: (String)

Returns:

  • (Module)


77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/kettle/wash.rb', line 77

def to_mod(constants:, path:)
  Module.new do
    define_method(:delete_const) do |*_args, &block|
      Kettle::Wash.delete_constants(self, constants)
      block&.call
      nil
    end

    define_method(:reset_const) do |*_args, &block|
      delete_const do
        block&.call
        load(path)
      end
    end
  end
end