Class: Users::KeysCountService

Inherits:
BaseCountService show all
Defined in:
app/services/users/keys_count_service.rb

Overview

Service class for getting the number of SSH keys that belong to a user.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseCountService

#cache_options, #count, #count_stored?, #delete_cache, #refresh_cache, #uncached_count, #update_cache_for_key

Constructor Details

#initialize(user) ⇒ KeysCountService

user - The User for which to get the number of SSH keys.


9
10
11
# File 'app/services/users/keys_count_service.rb', line 9

def initialize(user)
  @user = user
end

Instance Attribute Details

#userObject (readonly)

Returns the value of attribute user.


6
7
8
# File 'app/services/users/keys_count_service.rb', line 6

def user
  @user
end

Instance Method Details

#cache_keyObject


23
24
25
# File 'app/services/users/keys_count_service.rb', line 23

def cache_key
  "users/key-count-service/#{user.id}"
end

#raw?Boolean

Returns:

  • (Boolean)

17
18
19
20
21
# File 'app/services/users/keys_count_service.rb', line 17

def raw?
  # Since we're storing simple integers we don't need all of the additional
  # Marshal data Rails includes by default.
  true
end

#relation_for_countObject


13
14
15
# File 'app/services/users/keys_count_service.rb', line 13

def relation_for_count
  user.keys
end