Sha256: bd6b6e94f99aa043e971b153babbbcdb47060a89ba0a99d12e9016d1e15eeacd

Contents?: true

Size: 766 Bytes

Versions: 3

Compression:

Stored size: 766 Bytes

Contents

module Doorkeeper
  module Models
    module Mongoid3
      module Scopes
        extend ActiveSupport::Concern

        # It's strange that if not define these after included will raise error
        # in Mongoid 2 and 3, but 4 works well see:
        # https://travis-ci.org/jasl/doorkeeper/builds/31586902
        included do
          def scopes
            OAuth::Scopes.from_string(self[:scopes])
          end

          def scopes_string
            self[:scopes]
          end

          def includes_scope?(*required_scopes)
            required_scopes.blank? || required_scopes.any? { |s| scopes.exists?(s.to_s) }
          end

          def scopes=(value)
            write_attribute :scopes, value
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 3 rubygems

Version Path
doorkeeper-mongodb-3.0.0 lib/doorkeeper/orm/mongoid3/concerns/scopes.rb
dd-doorkeeper-mongodb-3.0.0 lib/doorkeeper/orm/mongoid3/concerns/scopes.rb
doorkeeper-2.2.2 lib/doorkeeper/orm/mongoid3/concerns/scopes.rb