class CabbageDoc::Authentication

Attributes

configurable[RW]
domain[RW]
json[RW]
password[RW]
path[RW]
scheme[RW]
subdomain[RW]
subdomains[RW]
tag[RW]
token[RW]
type[RW]
user_agent[RW]
username[RW]
verbose[RW]
visibility[RW]

Public Class Methods

new(request = nil, tag = nil) { |auth| ... } click to toggle source
Calls superclass method
# File lib/cabbage_doc/authentication.rb, line 4
def new(request = nil, tag = nil)
  super().tap do |auth|
    auth.tag = tag if tag
    yield(auth) if block_given?
    Configuration.instance.authentication.call(auth, request)
  end
end
new() click to toggle source
# File lib/cabbage_doc/authentication.rb, line 29
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
    @tag        = config.tags.first
    @json       = config.json
  end

  @subdomains = []
  @configurable = []
  @type = :basic
end

Public Instance Methods

configurable?() click to toggle source
# File lib/cabbage_doc/authentication.rb, line 67
def configurable?
  @configurable.any?
end
uri() click to toggle source
# File lib/cabbage_doc/authentication.rb, line 50
def uri
  if path && path != '/'
    "#{root_uri}/#{path}"
  else
    root_uri
  end
end
valid?() click to toggle source
# File lib/cabbage_doc/authentication.rb, line 58
def valid?
  case type
  when :basic
    username && password && valid_subdomain?
  else
    !token.nil? && valid_subdomain?
  end
end
visibility=(value) click to toggle source
# File lib/cabbage_doc/authentication.rb, line 46
def visibility=(value)
  @visibility = Array(value)
end

Private Instance Methods

root_uri() click to toggle source
# File lib/cabbage_doc/authentication.rb, line 77
def root_uri
  if subdomain
    "#{scheme}://#{subdomain}.#{domain}"
  else
    "#{scheme}://#{domain}"
  end
end
valid_subdomain?() click to toggle source
# File lib/cabbage_doc/authentication.rb, line 73
def valid_subdomain?
  !configurable.include?(:subdomain) || subdomain
end