Class: Arcp::Credentials::InMemoryStore
- Inherits:
-
CredentialStore
- Object
- CredentialStore
- Arcp::Credentials::InMemoryStore
- Defined in:
- lib/arcp/credential_provisioner.rb
Instance Method Summary collapse
- #all_outstanding ⇒ Object
- #forget(job_id:, credential_id:) ⇒ Object
-
#initialize ⇒ InMemoryStore
constructor
A new instance of InMemoryStore.
- #outstanding(job_id:) ⇒ Object
- #record(job_id:, credential_id:) ⇒ Object
Constructor Details
#initialize ⇒ InMemoryStore
Returns a new instance of InMemoryStore.
102 103 104 105 106 |
# File 'lib/arcp/credential_provisioner.rb', line 102 def initialize super @by_job = Hash.new { |hash, key| hash[key] = [] } @mutex = Mutex.new end |
Instance Method Details
#all_outstanding ⇒ Object
125 126 127 128 129 |
# File 'lib/arcp/credential_provisioner.rb', line 125 def all_outstanding @mutex.synchronize do @by_job.transform_values { |ids| ids.dup.freeze }.freeze end end |
#forget(job_id:, credential_id:) ⇒ Object
113 114 115 116 117 118 119 |
# File 'lib/arcp/credential_provisioner.rb', line 113 def forget(job_id:, credential_id:) @mutex.synchronize do @by_job[job_id].delete(credential_id) @by_job.delete(job_id) if @by_job[job_id].empty? end nil end |
#outstanding(job_id:) ⇒ Object
121 122 123 |
# File 'lib/arcp/credential_provisioner.rb', line 121 def outstanding(job_id:) @mutex.synchronize { @by_job[job_id].dup.freeze } end |
#record(job_id:, credential_id:) ⇒ Object
108 109 110 111 |
# File 'lib/arcp/credential_provisioner.rb', line 108 def record(job_id:, credential_id:) @mutex.synchronize { @by_job[job_id] |= [credential_id] } nil end |