Sha256: 3a064f68aa65a04ef581e8c8db4946868be7ca6da58b4505d4dbe2f5c1227a8a
Contents?: true
Size: 1.53 KB
Versions: 3
Compression:
Stored size: 1.53 KB
Contents
module CabbageDoc class Authentication class << self def new(request = nil) super().tap do |auth| yield(auth) if block_given? Configuration.instance.authentication.call(auth, request) end end end attr_accessor :type, :username, :password, :token, :domain, :subdomain, :subdomains, :scheme, :path, :user_agent, :configurable, :verbose, :visibility def initialize Configuration.instance.tap do |config| @domain = config.domain @scheme = config.scheme @path = config.path @user_agent = config.title @verbose = config.verbose @visibility = config.visibility.dup end @subdomains = [] @configurable = [] @type = :basic end def visibility=(value) @visibility = Array(value) end def uri if path && path != '/' "#{root_uri}/#{path}" else root_uri end end def valid? case type when :basic username && password when :token !token.nil? else false end end def configurable? @configurable.any? end private def root_uri if subdomain "#{scheme}://#{subdomain}.#{domain}" else "#{scheme}://#{domain}" end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
cabbage_doc-0.0.6 | lib/cabbage_doc/authentication.rb |
cabbage_doc-0.0.5 | lib/cabbage_doc/authentication.rb |
cabbage_doc-0.0.4 | lib/cabbage_doc/authentication.rb |