Module: Kettle::Wash
- Defined in:
- lib/kettle/wash.rb,
lib/kettle/wash/version.rb,
sig/kettle/wash.rbs
Defined Under Namespace
Modules: Version
Classes: Change, Error
Constant Summary
collapse
- VERSION =
Traditional Constant Location
Version::VERSION
Class Method Summary
collapse
Class Method Details
.delete_constants(owner, constants) ⇒ nil
30
31
32
33
34
35
|
# File 'lib/kettle/wash.rb', line 30
def delete_constants(owner, constants)
Array(constants).each do |constant_name|
owner.send(:remove_const, constant_name) if owner.const_defined?(constant_name, false)
end
nil
end
|
.install(owner, config = nil, constants: nil, path: nil) ⇒ nil
15
16
17
18
19
|
# File 'lib/kettle/wash.rb', line 15
def install(owner, config = nil, constants: nil, path: nil)
constants, path = normalize_config(config, constants: constants, path: path)
owner.extend(Change::ConstantChange.to_mod(constants: constants, path: path))
nil
end
|
.reset_constants(owner:, constants:, path:) ⇒ nil
37
38
39
40
41
|
# File 'lib/kettle/wash.rb', line 37
def reset_constants(owner:, constants:, path:)
delete_constants(owner, constants)
load(path)
nil
end
|
.validate!(owner, config = nil, constants: nil, path: nil) ⇒ true
21
22
23
24
25
26
27
28
|
# File 'lib/kettle/wash.rb', line 21
def validate!(owner, config = nil, constants: nil, path: nil)
constants, path = normalize_config(config, constants: constants, path: path)
missing = constants.reject { |constant_name| owner.const_defined?(constant_name, false) }
raise Error, "Missing washable constant(s): #{missing.join(", ")}" unless missing.empty?
raise Error, "Washable constants path does not exist: #{path}" unless File.file?(path)
true
end
|