Class: Module
- Inherits:
-
Object
- Object
- Module
- Defined in:
- lib/include_constants/core_ext/module.rb
Instance Method Summary collapse
Instance Method Details
#include_constants(*constants, from:) ⇒ Object
2 3 4 5 6 7 8 9 10 |
# File 'lib/include_constants/core_ext/module.rb', line 2 def include_constants(*constants, from:) constants = from.constants if constants.empty? constants.each do |constant| unless from.constants.include? constant raise "Cannot include the constant #{constant} from #{from}, because #{from} doesn't have one with such a name." end const_set constant, (const_get "#{from}::#{constant}") end end |