Exception: StrictIvars::NameError
- Inherits:
-
NameError
- Object
- NameError
- StrictIvars::NameError
- Defined in:
- lib/strict_ivars/name_error.rb
Constant Summary collapse
- INSTANCE_VARIABLE_METHOD =
Kernel.instance_method(:instance_variables)
Instance Method Summary collapse
-
#initialize(object, name) ⇒ NameError
constructor
A new instance of NameError.
Constructor Details
#initialize(object, name) ⇒ NameError
Returns a new instance of NameError.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/strict_ivars/name_error.rb', line 8 def initialize(object, name) checker = DidYouMean::SpellChecker.new( dictionary: INSTANCE_VARIABLE_METHOD.bind_call(object) ) suggestion = checker.correct(name).first = [ "Undefined instance variable `#{name}`.", ("Did you mean `#{suggestion}`?" if suggestion), ].join(" ") super() end |