Sha256: e49fa687370169a0d36332975e23ec3e61d3cf4e36ad8b27fe31b135b0e60122

Contents?: true

Size: 919 Bytes

Versions: 7

Compression:

Stored size: 919 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
    extend self

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

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

    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
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
doorkeeper-1.1.0 lib/doorkeeper/request.rb
doorkeeper-1.0.0 lib/doorkeeper/request.rb
doorkeeper-1.0.0.rc2 lib/doorkeeper/request.rb
doorkeeper-1.0.0.rc1 lib/doorkeeper/request.rb
doorkeeper-0.7.4 lib/doorkeeper/request.rb
doorkeeper-0.7.3 lib/doorkeeper/request.rb
doorkeeper-0.7.2 lib/doorkeeper/request.rb