Class: CommandTower::Username::Available
- Inherits:
-
Object
- Object
- CommandTower::Username::Available
- Defined in:
- app/services/command_tower/username/available.rb
Overview
Realtime username validity + availability lookup backed by the configured local cache. Shared by registration, admin/self-service attribute changes and the availability endpoint, so it stays a plain domain object rather than a capability service.
Defined Under Namespace
Classes: Availability
Constant Summary collapse
- REFRESH_KEY =
"username.refresh_after"- CACHE_MUTEX =
Mutex.new
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(username:, force_query: false) ⇒ Available
constructor
A new instance of Available.
Constructor Details
#initialize(username:, force_query: false) ⇒ Available
Returns a new instance of Available.
23 24 25 26 |
# File 'app/services/command_tower/username/available.rb', line 23 def initialize(username:, force_query: false) @username = username @force_query = force_query end |
Class Method Details
.call(username:, force_query: false) ⇒ Object
19 20 21 |
# File 'app/services/command_tower/username/available.rb', line 19 def self.call(username:, force_query: false) new(username:, force_query:).call end |
Instance Method Details
#call ⇒ Object
28 29 30 31 32 |
# File 'app/services/command_tower/username/available.rb', line 28 def call populate_local_cache! if refresh? Availability.new(valid: valid?, available: available?) end |