Class: Legion::Data::Encryption::KeyProvider
- Inherits:
-
Object
- Object
- Legion::Data::Encryption::KeyProvider
- Defined in:
- lib/legion/data/encryption/key_provider.rb
Instance Method Summary collapse
- #clear_cache! ⇒ Object
-
#initialize(mode: :auto) ⇒ KeyProvider
constructor
A new instance of KeyProvider.
- #key_for(tenant_id: nil) ⇒ Object
Constructor Details
#initialize(mode: :auto) ⇒ KeyProvider
Returns a new instance of KeyProvider.
9 10 11 12 |
# File 'lib/legion/data/encryption/key_provider.rb', line 9 def initialize(mode: :auto) @mode = mode @key_cache = {} end |
Instance Method Details
#clear_cache! ⇒ Object
19 20 21 |
# File 'lib/legion/data/encryption/key_provider.rb', line 19 def clear_cache! @key_cache.clear end |
#key_for(tenant_id: nil) ⇒ Object
14 15 16 17 |
# File 'lib/legion/data/encryption/key_provider.rb', line 14 def key_for(tenant_id: nil) cache_key = tenant_id || '__default__' @key_cache[cache_key] ||= derive_key(tenant_id) end |