class Apiphobic::Authorization::Authorizers::Scope
Attributes
action[RW]
audience[RW]
raw_parameters[RW]
scope_root[RW]
token[RW]
user[RW]
Public Class Methods
new(action:, token:, audience:, issuer:, parameters:, scope_root:, **other)
click to toggle source
rubocop:disable Metrics/ParameterLists
# File lib/apiphobic/authorization/authorizers/scope.rb, line 18 def initialize(action:, token:, audience:, issuer:, parameters:, scope_root:, **other) self.action = action self.audience = audience self.raw_parameters = parameters self.scope_root = scope_root self.token = token other.each do |name, value| public_send("#{name}=", value) end end
Public Instance Methods
call()
click to toggle source
# File lib/apiphobic/authorization/authorizers/scope.rb, line 41 def call if user.nil? public_scope else user_scope end end
public_scope()
click to toggle source
# File lib/apiphobic/authorization/authorizers/scope.rb, line 37 def public_scope scope_root.none end
user_scope()
click to toggle source
# File lib/apiphobic/authorization/authorizers/scope.rb, line 33 def user_scope scope_root.public_send("for_#{user_underscored_class_name}", scope_user_id) end
Private Instance Methods
scope_user_id()
click to toggle source
# File lib/apiphobic/authorization/authorizers/scope.rb, line 51 def scope_user_id authorized_scope_id(name: user_underscored_class_name, default: user.id) end
user_underscored_class_name()
click to toggle source
# File lib/apiphobic/authorization/authorizers/scope.rb, line 55 def user_underscored_class_name @user_underscored_class_name ||= begin base_user_class_name = user.class.name[/([^:]+)\z/, 1] base_user_class_name.underscore.downcase end end