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.



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

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

Instance Attribute Details

#ifObject (readonly)

Returns the value of attribute if.



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

def if
  @if
end

#nameObject (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?

Returns:

  • (Boolean)


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

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