Module: Ohai::Mixin::ConstantHelper
- Included in:
- System
- Defined in:
- lib/ohai/mixin/constant_helper.rb
Instance Method Summary collapse
- #recursive_remove_constants(object) ⇒ Object
- #remove_constants ⇒ Object
- #strict_const_defined?(object, const) ⇒ Boolean
Instance Method Details
#recursive_remove_constants(object) ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/ohai/mixin/constant_helper.rb', line 33 def recursive_remove_constants(object) if object.respond_to?(:constants) object.constants.each do |const| next unless strict_const_defined?(object, const) recursive_remove_constants(object.const_get(const)) object.send(:remove_const, const) end end end |
#remove_constants ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/ohai/mixin/constant_helper.rb', line 24 def remove_constants new_object_constants = Object.constants - @object_pristine.constants new_object_constants.each do |constant| Object.send(:remove_const, constant) unless Object.const_get(constant).is_a?(Module) end recursive_remove_constants(Ohai::NamedPlugin) end |
#strict_const_defined?(object, const) ⇒ Boolean
44 45 46 47 48 49 50 |
# File 'lib/ohai/mixin/constant_helper.rb', line 44 def strict_const_defined?(object, const) if object.method(:const_defined?).arity == 1 object.const_defined?(const) else object.const_defined?(const, false) end end |