Module: BracketErrorSuggestion
- Defined in:
- lib/bracket_error_suggestion.rb,
lib/bracket_error_suggestion/nil_ext.rb,
lib/bracket_error_suggestion/version.rb,
lib/bracket_error_suggestion/bracket_access.rb
Defined Under Namespace
Modules: BracketAccess, NilExt
Constant Summary
collapse
- VERSION =
"0.0.1"
Class Attribute Summary collapse
Class Method Summary
collapse
Class Attribute Details
.enabled ⇒ Object
Returns the value of attribute enabled.
7
8
9
|
# File 'lib/bracket_error_suggestion.rb', line 7
def enabled
@enabled
end
|
Class Method Details
.disable ⇒ Object
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/bracket_error_suggestion.rb', line 22
def disable
if block_given?
@enabled, backup = false, @enabled
begin
return yield
ensure
@enabled = backup
end
else
@enabled = false
nil_parent_paths.clear
end
end
|
.enable ⇒ Object
8
9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/bracket_error_suggestion.rb', line 8
def enable
if block_given?
@enabled, backup = true, @enabled
begin
return yield
ensure
@enabled = backup
nil_parent_paths.clear unless @enabled
end
else
@enabled = true
end
end
|
.nil_parent_paths ⇒ Object
36
37
38
|
# File 'lib/bracket_error_suggestion.rb', line 36
def nil_parent_paths
@nil_parent_paths ||= []
end
|