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(action:, token:, user:, issuer:, params:, scope_root:, **other) ⇒ Scope

rubocop:disable Metrics/ParameterLists



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

def initialize(action:, token:, user:, issuer:, params:, scope_root:, **other)
  self.action     = action
  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

#actionObject

Returns the value of attribute action.



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

def action
  @action
end

#paramsObject

Returns the value of attribute params.



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

def params
  @params
end

#scope_rootObject

Returns the value of attribute scope_root.



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

def scope_root
  @scope_root
end

#tokenObject

Returns the value of attribute token.



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

def token
  @token
end

#userObject

Returns the value of attribute user.



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

def user
  @user
end

Instance Method Details

#callObject



36
37
38
39
40
41
42
# File 'lib/drillbit/authorizers/scope.rb', line 36

def call
  if scope_user_id
    user_scope
  else
    public_scope
  end
end

#public_scopeObject



32
33
34
# File 'lib/drillbit/authorizers/scope.rb', line 32

def public_scope
  scope_root.none
end

#user_scopeObject

rubocop:enable Metrics/ParameterLists



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

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