Class: ActionController::AllowBrowser::BrowserBlocker
Do not use. This class is for internal use only.
Relationships & Source Files | |
Inherits: | Object |
Defined in: | actionpack/lib/action_controller/metal/allow_browser.rb |
Constant Summary
-
SETS =
# File 'actionpack/lib/action_controller/metal/allow_browser.rb', line 74{ modern: { safari: 17.2, chrome: 120, firefox: 121, opera: 106, ie: false } }
Class Method Summary
- .new(request, versions:) ⇒ BrowserBlocker constructor
Instance Attribute Summary
- #blocked? ⇒ Boolean readonly
- #request readonly
- #versions readonly
- #bot? ⇒ Boolean readonly private
- #unsupported_browser? ⇒ Boolean readonly private
- #user_agent_version_reported? ⇒ Boolean readonly private
- #version_below_minimum_required? ⇒ Boolean readonly private
- #version_guarded_browser? ⇒ Boolean readonly private
Instance Method Summary
- #expanded_versions private
- #minimum_browser_version_for_browser private
- #normalized_browser_name private
- #parsed_user_agent private
Constructor Details
.new(request, versions:) ⇒ BrowserBlocker
Instance Attribute Details
#blocked? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'actionpack/lib/action_controller/metal/allow_browser.rb', line 84
def blocked? user_agent_version_reported? && unsupported_browser? end
#bot? ⇒ Boolean
(readonly, private)
[ GitHub ]
# File 'actionpack/lib/action_controller/metal/allow_browser.rb', line 105
def bot? parsed_user_agent.bot? end
#request (readonly)
[ GitHub ]# File 'actionpack/lib/action_controller/metal/allow_browser.rb', line 78
attr_reader :request, :versions
#unsupported_browser? ⇒ Boolean
(readonly, private)
[ GitHub ]
# File 'actionpack/lib/action_controller/metal/allow_browser.rb', line 97
def unsupported_browser? version_guarded_browser? && version_below_minimum_required? && !bot? end
#user_agent_version_reported? ⇒ Boolean
(readonly, private)
[ GitHub ]
# File 'actionpack/lib/action_controller/metal/allow_browser.rb', line 93
def user_agent_version_reported? request.user_agent.present? && parsed_user_agent.version.to_s.present? end
#version_below_minimum_required? ⇒ Boolean
(readonly, private)
[ GitHub ]
# File 'actionpack/lib/action_controller/metal/allow_browser.rb', line 109
def version_below_minimum_required? if minimum_browser_version_for_browser parsed_user_agent.version < UserAgent::Version.new(minimum_browser_version_for_browser.to_s) else true end end
#version_guarded_browser? ⇒ Boolean
(readonly, private)
[ GitHub ]
# File 'actionpack/lib/action_controller/metal/allow_browser.rb', line 101
def version_guarded_browser? minimum_browser_version_for_browser != nil end
#versions (readonly)
[ GitHub ]# File 'actionpack/lib/action_controller/metal/allow_browser.rb', line 78
attr_reader :request, :versions
Instance Method Details
#expanded_versions (private)
[ GitHub ]#minimum_browser_version_for_browser (private)
[ GitHub ]# File 'actionpack/lib/action_controller/metal/allow_browser.rb', line 117
def minimum_browser_version_for_browser [normalized_browser_name] end
#normalized_browser_name (private)
[ GitHub ]# File 'actionpack/lib/action_controller/metal/allow_browser.rb', line 125
def normalized_browser_name case name = parsed_user_agent.browser.downcase when "internet explorer" then "ie" else name end end
#parsed_user_agent (private)
[ GitHub ]# File 'actionpack/lib/action_controller/metal/allow_browser.rb', line 89
def parsed_user_agent @parsed_user_agent ||= UserAgent.parse(request.user_agent) end