Module: Eco::Language::Klass::Const
- Included in:
- HelpersBuilt
- Defined in:
- lib/eco/language/klass/const.rb
Instance Method Summary collapse
-
#if_const(sym, at: self) ⇒ Object
rubocop:disable Naming/MethodParameterName.
- #redef_without_warning(sym, value) ⇒ Object
Instance Method Details
#if_const(sym, at: self) ⇒ Object
rubocop:disable Naming/MethodParameterName
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/eco/language/klass/const.rb', line 8 def if_const(sym, at: self) # rubocop:disable Naming/MethodParameterName value = nil value = at.const_get(sym) if at.const_defined?(sym) value.tap do next if value.nil? yield(value) end end |
#redef_without_warning(sym, value) ⇒ Object
3 4 5 6 |
# File 'lib/eco/language/klass/const.rb', line 3 def redef_without_warning(sym, value) self.class.send(:remove_const, sym) if self.class.const_defined?(sym) self.class.const_set(sym, value) end |