Module: Doorkeeper::Models::Scopes

Included in:
AccessGrant, AccessToken
Defined in:
lib/doorkeeper/models/scopes.rb

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/doorkeeper/models/scopes.rb', line 4

def self.included(base)
  base.class_eval do
    define_method :scopes do
      OAuth::Scopes.from_string(self[:scopes])
    end

    define_method :scopes_string do
      OAuth::Scopes.from_string(self[:scopes]).to_s
    end

    define_method :includes_scope? do |required_scopes|
      required_scopes.blank? || required_scopes.any? { |s| scopes.exists?(s) }
    end
  end
end