Class: Drillbit::Authorizers::Scope

Inherits:
Object
  • Object
show all
Defined in:
lib/drillbit/authorizers/scope.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(token:, user:, issuer:, params:, scope_root:, **other) ⇒ Scope

rubocop:disable Metrics/ParameterLists



13
14
15
16
17
18
19
20
21
22
# File 'lib/drillbit/authorizers/scope.rb', line 13

def initialize(token:, user:, issuer:, params:, scope_root:, **other)
  self.token      = token
  self.user       = user
  self.params     = params
  self.scope_root = scope_root

  other.each do |name, value|
    public_send("#{name}=", value)
  end
end

Instance Attribute Details

#paramsObject

Returns the value of attribute params.



7
8
9
# File 'lib/drillbit/authorizers/scope.rb', line 7

def params
  @params
end

#scope_rootObject

Returns the value of attribute scope_root.



7
8
9
# File 'lib/drillbit/authorizers/scope.rb', line 7

def scope_root
  @scope_root
end

#tokenObject

Returns the value of attribute token.



7
8
9
# File 'lib/drillbit/authorizers/scope.rb', line 7

def token
  @token
end

#userObject

Returns the value of attribute user.



7
8
9
# File 'lib/drillbit/authorizers/scope.rb', line 7

def user
  @user
end

Instance Method Details

#callObject



33
34
35
36
37
38
39
# File 'lib/drillbit/authorizers/scope.rb', line 33

def call
  if scope_user_id
    user_scope
  else
    public_scope
  end
end

#public_scopeObject



29
30
31
# File 'lib/drillbit/authorizers/scope.rb', line 29

def public_scope
  scope_root.none
end

#user_scopeObject

rubocop:enable Metrics/ParameterLists



25
26
27
# File 'lib/drillbit/authorizers/scope.rb', line 25

def user_scope
  scope_root.public_send("for_#{user_underscored_class_name}", scope_user_id)
end