Sha256: 3b533352ab6d76101ba57e82074e0f14c92da4b0489b441d73a5bdf308e4ba46

Contents?: true

Size: 493 Bytes

Versions: 1

Compression:

Stored size: 493 Bytes

Contents

require 'singleton'

module ProxyAuth
  # Service token
  class Token
    include Singleton

    attr_accessor :token

    def initialize
      register_service
    end

    def register_service
      Thread.new do
        set_token
      end
    end

    def valid?(token)
      @token == token
    end

    private

    def set_token
      connection = Connection.new
      3.times do
        @token = connection.service_token
        @token && break || sleep(5)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
proxy_auth-0.0.3 lib/proxy_auth/token.rb