Class: Gitlab::Auth::KeyStatusChecker

Inherits:
Object
  • Object
show all
Includes:
Utils::StrongMemoize
Defined in:
lib/gitlab/auth/key_status_checker.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

Constructor Details

#initialize(key) ⇒ KeyStatusChecker

Returns a new instance of KeyStatusChecker.


10
11
12
# File 'lib/gitlab/auth/key_status_checker.rb', line 10

def initialize(key)
  @key = key
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key


8
9
10
# File 'lib/gitlab/auth/key_status_checker.rb', line 8

def key
  @key
end

Instance Method Details

#console_messageObject


18
19
20
21
22
23
24
25
26
# File 'lib/gitlab/auth/key_status_checker.rb', line 18

def console_message
  strong_memoize(:console_message) do
    if key.expired?
      _('INFO: Your SSH key has expired. Please generate a new key.')
    elsif key.expires_soon?
      _('INFO: Your SSH key is expiring soon. Please generate a new key.')
    end
  end
end

#show_console_message?Boolean

Returns:

  • (Boolean)

14
15
16
# File 'lib/gitlab/auth/key_status_checker.rb', line 14

def show_console_message?
  console_message.present?
end