Module: HotwireNativeVersionGate::Concern
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/hotwire_native_version_gate/concern.rb
Instance Method Summary collapse
- #native_android?(min_version = nil) ⇒ Boolean
-
#native_app_platform ⇒ Object
Platform ("iOS" or "Android") from the Hotwire Native User-Agent, when present.
-
#native_app_version ⇒ Object
Semantic version from the Hotwire Native User-Agent prefix, when present.
- #native_feature?(feature) ⇒ Boolean
- #native_ios?(min_version = nil) ⇒ Boolean
Instance Method Details
#native_android?(min_version = nil) ⇒ Boolean
37 38 39 40 |
# File 'lib/hotwire_native_version_gate/concern.rb', line 37 def native_android?(min_version = nil) user_agent = respond_to?(:request) && request.respond_to?(:user_agent) ? request.user_agent : nil VersionGate.android?(user_agent, min_version) end |
#native_app_platform ⇒ Object
Platform ("iOS" or "Android") from the Hotwire Native User-Agent, when present. Returns nil when the request is not from a native app.
53 54 55 56 |
# File 'lib/hotwire_native_version_gate/concern.rb', line 53 def native_app_platform user_agent = respond_to?(:request) && request.respond_to?(:user_agent) ? request.user_agent : nil VersionGate.app_platform(user_agent) end |
#native_app_version ⇒ Object
Semantic version from the Hotwire Native User-Agent prefix, when present. Returns nil when the request is not from a native app, or when no version is present.
44 45 46 47 48 49 |
# File 'lib/hotwire_native_version_gate/concern.rb', line 44 def native_app_version return unless native_ios? || native_android? user_agent = respond_to?(:request) && request.respond_to?(:user_agent) ? request.user_agent : nil VersionGate.app_version(user_agent) end |
#native_feature?(feature) ⇒ Boolean
27 28 29 30 |
# File 'lib/hotwire_native_version_gate/concern.rb', line 27 def native_feature?(feature) user_agent = respond_to?(:request) && request.respond_to?(:user_agent) ? request.user_agent : nil VersionGate.feature_enabled?(feature, user_agent, context: self) end |
#native_ios?(min_version = nil) ⇒ Boolean
32 33 34 35 |
# File 'lib/hotwire_native_version_gate/concern.rb', line 32 def native_ios?(min_version = nil) user_agent = respond_to?(:request) && request.respond_to?(:user_agent) ? request.user_agent : nil VersionGate.ios?(user_agent, min_version) end |