Module: Grant::Status
Defined Under Namespace
Modules: MonoThread, MultiThread
Class Method Summary
collapse
Methods included from MonoThread
included
Class Method Details
.disable_grant ⇒ Object
76
77
78
|
# File 'lib/grant/status.rb', line 76
def disable_grant
self.is_grant_disabled = true
end
|
.enable_grant ⇒ Object
80
81
82
|
# File 'lib/grant/status.rb', line 80
def enable_grant
self.is_grant_disabled = false
end
|
.grant_disabled? ⇒ Boolean
65
66
67
|
# File 'lib/grant/status.rb', line 65
def grant_disabled?
is_grant_disabled == true
end
|
.grant_enabled? ⇒ Boolean
69
70
71
|
# File 'lib/grant/status.rb', line 69
def grant_enabled?
! grant_disabled?
end
|
.switch_to_monothread ⇒ Object
58
59
60
|
# File 'lib/grant/status.rb', line 58
def switch_to_monothread
Grant::Status.send :include, MonoThread
end
|
.switch_to_multithread ⇒ Object
Change to global status (use ONLY in test env)
55
56
57
|
# File 'lib/grant/status.rb', line 55
def switch_to_multithread
Grant::Status.send :include, MultiThread
end
|
.with_grant ⇒ Object
97
98
99
100
101
102
103
104
105
106
107
108
|
# File 'lib/grant/status.rb', line 97
def with_grant
previously_disabled = grant_disabled?
begin
enable_grant
result = yield if block_given?
ensure
disable_grant if previously_disabled
end
result
end
|
.without_grant ⇒ Object
84
85
86
87
88
89
90
91
92
93
94
95
|
# File 'lib/grant/status.rb', line 84
def without_grant
previously_disabled = grant_disabled?
begin
disable_grant
result = yield if block_given?
ensure
enable_grant unless previously_disabled
end
result
end
|