Class: Garage::TokenScope
- Inherits:
-
Object
- Object
- Garage::TokenScope
show all
- Defined in:
- lib/garage/token_scope.rb
Defined Under Namespace
Classes: Ability, Config, Scope
Class Method Summary
collapse
Class Method Details
.ability(user, scopes) ⇒ Object
28
29
30
31
32
|
# File 'lib/garage/token_scope.rb', line 28
def self.ability(user, scopes)
scopes = scopes.map(&:to_sym)
scopes = [:public] if scopes.empty? Ability.new(user, configuration.scopes.slice(*scopes).values)
end
|
.all_scopes ⇒ Object
12
13
14
|
# File 'lib/garage/token_scope.rb', line 12
def self.all_scopes
configuration.scopes.values
end
|
.configuration ⇒ Object
8
9
10
|
# File 'lib/garage/token_scope.rb', line 8
def self.configuration
@config or raise "Garage::TokenScope.configure must be called in initializer"
end
|
3
4
5
6
|
# File 'lib/garage/token_scope.rb', line 3
def self.configure(&block)
@config = Config.new
@config.instance_eval(&block)
end
|
.hidden_scopes ⇒ Object
24
25
26
|
# File 'lib/garage/token_scope.rb', line 24
def self.hidden_scopes
configuration.scopes.values.select(&:hidden?)
end
|
.optional_scopes ⇒ Object
16
17
18
|
# File 'lib/garage/token_scope.rb', line 16
def self.optional_scopes
configuration.scopes.values.select(&:optional?)
end
|
.revealed_scopes ⇒ Object
20
21
22
|
# File 'lib/garage/token_scope.rb', line 20
def self.revealed_scopes
configuration.scopes.values.reject(&:hidden?)
end
|