Class: CoreLibrary::And

Inherits:
AuthGroup
  • Object
show all
Defined in:
lib/apimatic-core/authentication/multiple/and_auth_group.rb

Overview

The class to handle the AND combination of multiple authentications.

Instance Attribute Summary

Attributes inherited from AuthGroup

#auth_participants, #error_messages, #is_valid_group, #mapped_group

Instance Method Summary collapse

Methods inherited from AuthGroup

#apply, #with_auth_managers

Constructor Details

#initialize(*auth_group) ⇒ And

Returns a new instance of And.



10
11
12
13
# File 'lib/apimatic-core/authentication/multiple/and_auth_group.rb', line 10

def initialize(*auth_group)
  super auth_group
  @is_valid_group = true
end

Instance Method Details

#error_messageString

Getter for the error message for auth.

Returns:

  • (String)

    The error message while applying the auth.



6
7
8
# File 'lib/apimatic-core/authentication/multiple/and_auth_group.rb', line 6

def error_message
  @error_messages.join(' and ')
end

#validBoolean

Checks if the associated auth is valid.

Returns:

  • (Boolean)

    True if the associated auth is valid, false otherwise.



17
18
19
20
21
22
23
24
25
26
# File 'lib/apimatic-core/authentication/multiple/and_auth_group.rb', line 17

def valid
  @mapped_group.each do |participant|
    unless participant.valid
      @error_messages.append(participant.error_message)
      @is_valid_group = false
    end
  end

  @is_valid_group
end