class ServerTiming::Auth
Encapsulates logic that determines whether the user is properly authorized to view server timing response headers.
Public Class Methods
deny!()
click to toggle source
# File lib/server_timing/auth.rb, line 8 def self.deny! self.state=false end
ok!()
click to toggle source
# File lib/server_timing/auth.rb, line 4 def self.ok! self.state=true end
permitted?()
click to toggle source
# File lib/server_timing/auth.rb, line 28 def self.permitted? if state return true elsif state.is_a?(FalseClass) return false else # implied access - state has not been set # If not Rails, return true return true if !ServerTiming.rails? # If in a non-production environment, permit return true if !Rails.env.production? # In production, return false if no state has been set return false if Rails.env.production? end end
reset!()
click to toggle source
# File lib/server_timing/auth.rb, line 12 def self.reset! self.state=nil end
state()
click to toggle source
Can be one of three values:
-
true
-
false
-
nil (default)
# File lib/server_timing/auth.rb, line 24 def self.state Thread.current[:server_timing_authorized] end
state=(new_state)
click to toggle source
# File lib/server_timing/auth.rb, line 16 def self.state=(new_state) Thread.current[:server_timing_authorized] = new_state end