module Doorkeeper::Request

def authorization_strategy(strategy)

def authorization_strategy(strategy)
  get_strategy strategy, %w[code token]
rescue NameError
  raise Errors::InvalidAuthorizationStrategy
end

def get_strategy(strategy, available)

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

def token_strategy(strategy)

def token_strategy(strategy)
  get_strategy strategy, %w[password client_credentials authorization_code refresh_token]
rescue NameError
  raise Errors::InvalidTokenStrategy
end