Sha256: 7253a60950afe1719d1f245dcc7a666d73dd7dcdc6f8e435afa419fd8d1ea012

Contents?: true

Size: 938 Bytes

Versions: 23

Compression:

Stored size: 938 Bytes

Contents

require 'doorkeeper/request/authorization_code'
require 'doorkeeper/request/client_credentials'
require 'doorkeeper/request/code'
require 'doorkeeper/request/password'
require 'doorkeeper/request/refresh_token'
require 'doorkeeper/request/token'

module Doorkeeper
  module Request
    module_function

    def authorization_strategy(strategy)
      get_strategy strategy, Doorkeeper.configuration.authorization_response_types
    rescue NameError
      raise Errors::InvalidAuthorizationStrategy
    end

    def token_strategy(strategy)
      get_strategy strategy, Doorkeeper.configuration.token_grant_types
    rescue NameError
      raise Errors::InvalidTokenStrategy
    end

    def get_strategy(strategy, available)
      fail Errors::MissingRequestStrategy unless strategy.present?
      fail NameError unless available.include?(strategy.to_s)
      "Doorkeeper::Request::#{strategy.to_s.camelize}".constantize
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
doorkeeper-1.3.1 lib/doorkeeper/request.rb
doorkeeper-1.3.0 lib/doorkeeper/request.rb
doorkeeper-1.2.0 lib/doorkeeper/request.rb