Class: PublishingPlatform::SSO::AuthoriseUser
- Inherits:
-
Object
- Object
- PublishingPlatform::SSO::AuthoriseUser
- Defined in:
- lib/publishing_platform_sso/authorise_user.rb
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(current_user, permissions) ⇒ AuthoriseUser
constructor
A new instance of AuthoriseUser.
Constructor Details
#initialize(current_user, permissions) ⇒ AuthoriseUser
Returns a new instance of AuthoriseUser.
6 7 8 9 |
# File 'lib/publishing_platform_sso/authorise_user.rb', line 6 def initialize(current_user, ) @current_user = current_user @permissions = end |
Class Method Details
.call ⇒ Object
4 |
# File 'lib/publishing_platform_sso/authorise_user.rb', line 4 def self.call(...) = new(...).call |
Instance Method Details
#call ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/publishing_platform_sso/authorise_user.rb', line 11 def call case when String unless current_user.() raise PublishingPlatform::SSO::PermissionDeniedError, "Sorry, you don't seem to have the #{} permission for this app." end when Hash raise ArgumentError, "Must be either `any_of` or `all_of`" unless .keys.size == 1 if [:any_of] ([:any_of]) elsif [:all_of] ([:all_of]) else raise ArgumentError, "Must be either `any_of` or `all_of`" end end end |