Class: API::Scope

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, options = {}) ⇒ Scope

Returns a new instance of Scope.


8
9
10
11
# File 'lib/api/scope.rb', line 8

def initialize(name, options = {})
  @name = name.to_sym
  @if = options[:if]
end

Instance Attribute Details

#ifObject (readonly)

Returns the value of attribute if


6
7
8
# File 'lib/api/scope.rb', line 6

def if
  @if
end

#nameObject (readonly)

Returns the value of attribute name


6
7
8
# File 'lib/api/scope.rb', line 6

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?

Returns:

  • (Boolean)

15
16
17
# File 'lib/api/scope.rb', line 15

def sufficient?(scopes, request)
  scopes.include?(self.name) && verify_if_condition(request)
end