Class: CabbageDoc::Authentication

Inherits:
Object
  • Object
show all
Defined in:
lib/cabbage_doc/authentication.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeAuthentication

Returns a new instance of Authentication.



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/cabbage_doc/authentication.rb', line 25

def initialize
  Configuration.instance.tap do |config|
    @domain     = config.domain
    @scheme     = config.scheme
    @path       = config.path
    @user_agent = config.title
  end

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

Instance Attribute Details

#configurableObject

Returns the value of attribute configurable.



12
13
14
# File 'lib/cabbage_doc/authentication.rb', line 12

def configurable
  @configurable
end

#domainObject

Returns the value of attribute domain.



12
13
14
# File 'lib/cabbage_doc/authentication.rb', line 12

def domain
  @domain
end

#passwordObject

Returns the value of attribute password.



12
13
14
# File 'lib/cabbage_doc/authentication.rb', line 12

def password
  @password
end

#pathObject

Returns the value of attribute path.



12
13
14
# File 'lib/cabbage_doc/authentication.rb', line 12

def path
  @path
end

#schemeObject

Returns the value of attribute scheme.



12
13
14
# File 'lib/cabbage_doc/authentication.rb', line 12

def scheme
  @scheme
end

#subdomainObject

Returns the value of attribute subdomain.



12
13
14
# File 'lib/cabbage_doc/authentication.rb', line 12

def subdomain
  @subdomain
end

#subdomainsObject

Returns the value of attribute subdomains.



12
13
14
# File 'lib/cabbage_doc/authentication.rb', line 12

def subdomains
  @subdomains
end

#tokenObject

Returns the value of attribute token.



12
13
14
# File 'lib/cabbage_doc/authentication.rb', line 12

def token
  @token
end

#typeObject

Returns the value of attribute type.



12
13
14
# File 'lib/cabbage_doc/authentication.rb', line 12

def type
  @type
end

#user_agentObject

Returns the value of attribute user_agent.



12
13
14
# File 'lib/cabbage_doc/authentication.rb', line 12

def user_agent
  @user_agent
end

#usernameObject

Returns the value of attribute username.



12
13
14
# File 'lib/cabbage_doc/authentication.rb', line 12

def username
  @username
end

#verboseObject

Returns the value of attribute verbose.



12
13
14
# File 'lib/cabbage_doc/authentication.rb', line 12

def verbose
  @verbose
end

Class Method Details

.new(request = nil) ⇒ Object



4
5
6
7
8
9
# File 'lib/cabbage_doc/authentication.rb', line 4

def new(request = nil)
  super().tap do |auth|
    yield(auth) if block_given?
    Configuration.instance.authentication.call(auth, request)
  end
end

Instance Method Details

#configurable?Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/cabbage_doc/authentication.rb', line 50

def configurable?
  @configurable.any?
end

#valid?Boolean

Returns:

  • (Boolean)


39
40
41
42
43
44
45
46
47
48
# File 'lib/cabbage_doc/authentication.rb', line 39

def valid?
  case type
  when :basic
    username && password
  when :token
    !token.nil?
  else
    false
  end
end