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.
-
#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.
-
#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.
Class Method Summary collapse
Instance Method Summary collapse
- #configurable? ⇒ Boolean
-
#initialize ⇒ Authentication
constructor
A new instance of Authentication.
- #valid? ⇒ Boolean
Constructor Details
#initialize ⇒ Authentication
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
#configurable ⇒ Object
Returns the value of attribute configurable.
12 13 14 |
# File 'lib/cabbage_doc/authentication.rb', line 12 def configurable @configurable end |
#domain ⇒ Object
Returns the value of attribute domain.
12 13 14 |
# File 'lib/cabbage_doc/authentication.rb', line 12 def domain @domain end |
#password ⇒ Object
Returns the value of attribute password.
12 13 14 |
# File 'lib/cabbage_doc/authentication.rb', line 12 def password @password end |
#path ⇒ Object
Returns the value of attribute path.
12 13 14 |
# File 'lib/cabbage_doc/authentication.rb', line 12 def path @path end |
#scheme ⇒ Object
Returns the value of attribute scheme.
12 13 14 |
# File 'lib/cabbage_doc/authentication.rb', line 12 def scheme @scheme end |
#subdomain ⇒ Object
Returns the value of attribute subdomain.
12 13 14 |
# File 'lib/cabbage_doc/authentication.rb', line 12 def subdomain @subdomain end |
#subdomains ⇒ Object
Returns the value of attribute subdomains.
12 13 14 |
# File 'lib/cabbage_doc/authentication.rb', line 12 def subdomains @subdomains end |
#token ⇒ Object
Returns the value of attribute token.
12 13 14 |
# File 'lib/cabbage_doc/authentication.rb', line 12 def token @token end |
#type ⇒ Object
Returns the value of attribute type.
12 13 14 |
# File 'lib/cabbage_doc/authentication.rb', line 12 def type @type end |
#user_agent ⇒ Object
Returns the value of attribute user_agent.
12 13 14 |
# File 'lib/cabbage_doc/authentication.rb', line 12 def user_agent @user_agent end |
#username ⇒ Object
Returns the value of attribute username.
12 13 14 |
# File 'lib/cabbage_doc/authentication.rb', line 12 def username @username end |
#verbose ⇒ Object
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
50 51 52 |
# File 'lib/cabbage_doc/authentication.rb', line 50 def configurable? @configurable.any? end |
#valid? ⇒ 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 |