Class: Grape::OAuth2::Scopes
- Inherits:
-
Object
- Object
- Grape::OAuth2::Scopes
- Defined in:
- lib/grape_oauth2/scopes.rb
Overview
OAuth2 helper for scopes validation (between requested and presented in Access Token).
Instance Attribute Summary collapse
-
#scopes ⇒ Array<String>
readonly
Array of requested scopes.
Instance Method Summary collapse
-
#initialize(scopes) ⇒ Scopes
constructor
Helper class initializer.
-
#valid_for?(access_token) ⇒ Boolean
Checks if requested scopes (passed and processed on initialization) are presented in the Access Token.
Constructor Details
#initialize(scopes) ⇒ Scopes
Helper class initializer.
17 18 19 |
# File 'lib/grape_oauth2/scopes.rb', line 17 def initialize(scopes) @scopes = to_array(scopes || []) end |
Instance Attribute Details
#scopes ⇒ Array<String> (readonly)
Array of requested scopes
10 11 12 |
# File 'lib/grape_oauth2/scopes.rb', line 10 def scopes @scopes end |
Instance Method Details
#valid_for?(access_token) ⇒ Boolean
Checks if requested scopes (passed and processed on initialization) are presented in the Access Token.
31 32 33 |
# File 'lib/grape_oauth2/scopes.rb', line 31 def valid_for?(access_token) scopes.empty? || present_in?(access_token.scopes) end |