module BitBucket::Validations::Token

Constants

TOKEN_REQUIRED
TOKEN_REQUIRED_REGEXP

Public Instance Methods

validates_token_for(method, path) click to toggle source

Ensures that required authentication token is present before request is sent.

# File lib/bitbucket_rest_api/validations/token.rb, line 27
def validates_token_for(method, path)
  return true unless TOKEN_REQUIRED.grep("#{method} #{path}").empty?

  token_required = false
  TOKEN_REQUIRED_REGEXP.each do |regex|
    token_required = true if "#{method} #{path}" =~ regex
  end
  token_required
end