Class: CoreLibrary::AuthGroup
- Inherits:
-
Authentication
- Object
- Authentication
- CoreLibrary::AuthGroup
- Defined in:
- lib/apimatic-core/authentication/multiple/auth_group.rb
Overview
The parent class of multiple authentication groups (i.e. Or & And groups). This parent class is responsible for handling multiple auths on a particular request.
Instance Attribute Summary collapse
-
#auth_participants ⇒ Object
Returns the value of attribute auth_participants.
-
#error_messages ⇒ Object
Returns the value of attribute error_messages.
-
#is_valid_group ⇒ Object
Returns the value of attribute is_valid_group.
-
#mapped_group ⇒ Object
Returns the value of attribute mapped_group.
Instance Method Summary collapse
-
#apply(http_request) ⇒ Object
Applies the associated auth to the HTTP request.
-
#initialize(auth_group) ⇒ AuthGroup
constructor
Initializes a new instance of AuthGroup.
-
#valid ⇒ Boolean
Checks if the associated auth is valid.
-
#with_auth_managers(auth_managers) ⇒ Single
Extracts out the auth from the given auth managers.
Constructor Details
#initialize(auth_group) ⇒ AuthGroup
Initializes a new instance of AuthGroup.
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/apimatic-core/authentication/multiple/auth_group.rb', line 9 def initialize(auth_group) @auth_participants = [] auth_group.each do |auth_participant| if !auth_participant.nil? && auth_participant.is_a?(String) @auth_participants.append(Single.new(auth_participant)) elsif !auth_participant.nil? @auth_participants.append(auth_participant) end @mapped_group = [] @error_messages = [] @is_valid_group = nil end end |
Instance Attribute Details
#auth_participants ⇒ Object
Returns the value of attribute auth_participants.
5 6 7 |
# File 'lib/apimatic-core/authentication/multiple/auth_group.rb', line 5 def auth_participants @auth_participants end |
#error_messages ⇒ Object
Returns the value of attribute error_messages.
5 6 7 |
# File 'lib/apimatic-core/authentication/multiple/auth_group.rb', line 5 def @error_messages end |
#is_valid_group ⇒ Object
Returns the value of attribute is_valid_group.
5 6 7 |
# File 'lib/apimatic-core/authentication/multiple/auth_group.rb', line 5 def is_valid_group @is_valid_group end |
#mapped_group ⇒ Object
Returns the value of attribute mapped_group.
5 6 7 |
# File 'lib/apimatic-core/authentication/multiple/auth_group.rb', line 5 def mapped_group @mapped_group end |
Instance Method Details
#apply(http_request) ⇒ Object
Applies the associated auth to the HTTP request.
41 42 43 44 45 |
# File 'lib/apimatic-core/authentication/multiple/auth_group.rb', line 41 def apply(http_request) return unless @is_valid_group @mapped_group.each { |participant| participant.apply(http_request) } end |
#valid ⇒ Boolean
Checks if the associated auth is valid.
35 36 37 |
# File 'lib/apimatic-core/authentication/multiple/auth_group.rb', line 35 def valid raise NotImplementedError, 'This method needs to be implemented in a child class.' end |
#with_auth_managers(auth_managers) ⇒ Single
Extracts out the auth from the given auth managers.
26 27 28 29 30 31 |
# File 'lib/apimatic-core/authentication/multiple/auth_group.rb', line 26 def with_auth_managers(auth_managers) @auth_participants.each do |participant| @mapped_group.append(participant.with_auth_managers(auth_managers)) end self end |