Class: API::Scope
- Inherits:
-
Object
- Object
- API::Scope
- Defined in:
- lib/api/scope.rb
Instance Attribute Summary collapse
-
#if ⇒ Object
readonly
Returns the value of attribute if.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(name, options = {}) ⇒ Scope
constructor
A new instance of Scope.
-
#sufficient?(scopes, request) ⇒ Boolean
Are the ‘scopes` passed in sufficient to adequately authorize the passed request for the scope represented by the current instance of this class?.
Constructor Details
#initialize(name, options = {}) ⇒ Scope
Returns a new instance of Scope.
9 10 11 12 |
# File 'lib/api/scope.rb', line 9 def initialize(name, = {}) @name = name.to_sym @if = [:if] end |
Instance Attribute Details
#if ⇒ Object (readonly)
Returns the value of attribute if.
7 8 9 |
# File 'lib/api/scope.rb', line 7 def if @if end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/api/scope.rb', line 7 def name @name end |
Instance Method Details
#sufficient?(scopes, request) ⇒ Boolean
Are the ‘scopes` passed in sufficient to adequately authorize the passed request for the scope represented by the current instance of this class?
16 17 18 |
# File 'lib/api/scope.rb', line 16 def sufficient?(scopes, request) scopes.include?(self.name) && verify_if_condition(request) end |