Class: Smith::Artifacts::ScopedStore
- Inherits:
-
Object
- Object
- Smith::Artifacts::ScopedStore
- Defined in:
- lib/smith/artifacts/scoped_store.rb
Instance Method Summary collapse
- #expired(retention: nil) ⇒ Object
- #fetch(ref) ⇒ Object
-
#initialize(backend:, namespace:) ⇒ ScopedStore
constructor
A new instance of ScopedStore.
- #store(data, content_type: "application/octet-stream") ⇒ Object
Constructor Details
#initialize(backend:, namespace:) ⇒ ScopedStore
Returns a new instance of ScopedStore.
6 7 8 9 |
# File 'lib/smith/artifacts/scoped_store.rb', line 6 def initialize(backend:, namespace:) @backend = backend @namespace = namespace end |
Instance Method Details
#expired(retention: nil) ⇒ Object
23 24 25 26 |
# File 'lib/smith/artifacts/scoped_store.rb', line 23 def expired(retention: nil) @backend.expired(retention: retention, execution_namespace: @namespace) .map { |ref| "#{@namespace}:#{ref}" } end |
#fetch(ref) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/smith/artifacts/scoped_store.rb', line 16 def fetch(ref) return nil unless ref.start_with?("#{@namespace}:") inner_ref = ref.delete_prefix("#{@namespace}:") @backend.fetch(inner_ref) end |
#store(data, content_type: "application/octet-stream") ⇒ Object
11 12 13 14 |
# File 'lib/smith/artifacts/scoped_store.rb', line 11 def store(data, content_type: "application/octet-stream") inner_ref = @backend.store(data, content_type: content_type, execution_namespace: @namespace) "#{@namespace}:#{inner_ref}" end |