Module: AppIdentity::Versions
- Extended by:
- Validation
- Defined in:
- lib/app_identity/versions.rb
Overview
:nodoc:
Defined Under Namespace
Classes: Base, RandomNonce, TimestampNonce, V1, V2, V3, V4
Class Method Summary collapse
-
.[](version) ⇒ Object
Looks up the version instance by version.
-
.allow(*versions) ⇒ Object
Globally allow the listed versions.
-
.allowed!(version, provided = nil) ⇒ Object
Tests that the version is valid and not explicitly disallowed or raises an exception.
-
.allowed?(version, provided = nil) ⇒ Boolean
Checks to see if the version is valid and not explicitly disallowed, either in the provided list or in global list.
-
.disallow(*versions) ⇒ Object
Globally disallow the listed versions.
-
.valid!(version) ⇒ Object
Tests that the version is valid or raises an exception.
-
.valid?(version) ⇒ Boolean
Checks to see if the version has been defined.
Methods included from Validation
validate_config, validate_id, validate_padlock, validate_secret, validate_version
Class Method Details
.[](version) ⇒ Object
Looks up the version instance by version.
144 145 146 |
# File 'lib/app_identity/versions.rb', line 144 def [](version) # :nodoc: AppIdentity::Versions::Base.defined.fetch(version) end |
.allow(*versions) ⇒ Object
Globally allow the listed versions.
179 180 181 |
# File 'lib/app_identity/versions.rb', line 179 def allow(*versions) disallowed.subtract(coerce_versions(versions)) end |
.allowed!(version, provided = nil) ⇒ Object
Tests that the version is valid and not explicitly disallowed or raises an exception.
168 169 170 171 |
# File 'lib/app_identity/versions.rb', line 168 def allowed!(version, provided = nil) return true if valid!(version) && allowed?(version, provided) raise AppIdentity::Error, "version #{version} has been disallowed" end |
.allowed?(version, provided = nil) ⇒ Boolean
Checks to see if the version is valid and not explicitly disallowed, either in the provided list or in global list.
161 162 163 164 |
# File 'lib/app_identity/versions.rb', line 161 def allowed?(version, provided = nil) valid?(version) && !disallowed.member?(version) && !Set.new(provided).member?(version) end |
.disallow(*versions) ⇒ Object
Globally disallow the listed versions.
174 175 176 |
# File 'lib/app_identity/versions.rb', line 174 def disallow(*versions) disallowed.merge(coerce_versions(versions)) end |
.valid!(version) ⇒ Object
Tests that the version is valid or raises an exception.
154 155 156 157 |
# File 'lib/app_identity/versions.rb', line 154 def valid!(version) # :nodoc: return true if valid?(version) raise AppIdentity::Error, "version must be one of #{AppIdentity::Versions::Base.defined.keys}" end |
.valid?(version) ⇒ Boolean
Checks to see if the version has been defined.
149 150 151 |
# File 'lib/app_identity/versions.rb', line 149 def valid?(version) # :nodoc: AppIdentity::Versions::Base.defined.has_key?(version) end |