Class: CabbageDoc::Authentication
- Inherits:
-
Object
- Object
- CabbageDoc::Authentication
- Defined in:
- lib/cabbage_doc/authentication.rb
Instance Attribute Summary collapse
-
#configurable ⇒ Object
Returns the value of attribute configurable.
-
#domain ⇒ Object
Returns the value of attribute domain.
-
#json ⇒ Object
Returns the value of attribute json.
-
#password ⇒ Object
Returns the value of attribute password.
-
#path ⇒ Object
Returns the value of attribute path.
-
#scheme ⇒ Object
Returns the value of attribute scheme.
-
#subdomain ⇒ Object
Returns the value of attribute subdomain.
-
#subdomains ⇒ Object
Returns the value of attribute subdomains.
-
#tag ⇒ Object
Returns the value of attribute tag.
-
#token ⇒ Object
Returns the value of attribute token.
-
#type ⇒ Object
Returns the value of attribute type.
-
#user_agent ⇒ Object
Returns the value of attribute user_agent.
-
#username ⇒ Object
Returns the value of attribute username.
-
#verbose ⇒ Object
Returns the value of attribute verbose.
-
#visibility ⇒ Object
Returns the value of attribute visibility.
Class Method Summary collapse
Instance Method Summary collapse
- #configurable? ⇒ Boolean
-
#initialize ⇒ Authentication
constructor
A new instance of Authentication.
- #uri ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize ⇒ Authentication
Returns a new instance of Authentication.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# 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..first @json = config.json end @subdomains = [] @configurable = [] @type = :basic end |
Instance Attribute Details
#configurable ⇒ Object
Returns the value of attribute configurable.
13 14 15 |
# File 'lib/cabbage_doc/authentication.rb', line 13 def configurable @configurable end |
#domain ⇒ Object
Returns the value of attribute domain.
13 14 15 |
# File 'lib/cabbage_doc/authentication.rb', line 13 def domain @domain end |
#json ⇒ Object
Returns the value of attribute json.
13 14 15 |
# File 'lib/cabbage_doc/authentication.rb', line 13 def json @json end |
#password ⇒ Object
Returns the value of attribute password.
13 14 15 |
# File 'lib/cabbage_doc/authentication.rb', line 13 def password @password end |
#path ⇒ Object
Returns the value of attribute path.
13 14 15 |
# File 'lib/cabbage_doc/authentication.rb', line 13 def path @path end |
#scheme ⇒ Object
Returns the value of attribute scheme.
13 14 15 |
# File 'lib/cabbage_doc/authentication.rb', line 13 def scheme @scheme end |
#subdomain ⇒ Object
Returns the value of attribute subdomain.
13 14 15 |
# File 'lib/cabbage_doc/authentication.rb', line 13 def subdomain @subdomain end |
#subdomains ⇒ Object
Returns the value of attribute subdomains.
13 14 15 |
# File 'lib/cabbage_doc/authentication.rb', line 13 def subdomains @subdomains end |
#tag ⇒ Object
Returns the value of attribute tag.
13 14 15 |
# File 'lib/cabbage_doc/authentication.rb', line 13 def tag @tag end |
#token ⇒ Object
Returns the value of attribute token.
13 14 15 |
# File 'lib/cabbage_doc/authentication.rb', line 13 def token @token end |
#type ⇒ Object
Returns the value of attribute type.
13 14 15 |
# File 'lib/cabbage_doc/authentication.rb', line 13 def type @type end |
#user_agent ⇒ Object
Returns the value of attribute user_agent.
13 14 15 |
# File 'lib/cabbage_doc/authentication.rb', line 13 def user_agent @user_agent end |
#username ⇒ Object
Returns the value of attribute username.
13 14 15 |
# File 'lib/cabbage_doc/authentication.rb', line 13 def username @username end |
#verbose ⇒ Object
Returns the value of attribute verbose.
13 14 15 |
# File 'lib/cabbage_doc/authentication.rb', line 13 def verbose @verbose end |
#visibility ⇒ Object
Returns the value of attribute visibility.
13 14 15 |
# File 'lib/cabbage_doc/authentication.rb', line 13 def visibility @visibility end |
Class Method Details
.new(request = nil, tag = nil) ⇒ Object
4 5 6 7 8 9 10 |
# 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 |
Instance Method Details
#configurable? ⇒ Boolean
67 68 69 |
# File 'lib/cabbage_doc/authentication.rb', line 67 def configurable? @configurable.any? end |
#uri ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/cabbage_doc/authentication.rb', line 50 def uri if path && path != '/' "#{root_uri}/#{path}" else root_uri end end |
#valid? ⇒ Boolean
58 59 60 61 62 63 64 65 |
# 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 |