Class: Smith::Artifacts::ScopedStore

Inherits:
Object
  • Object
show all
Defined in:
lib/smith/artifacts/scoped_store.rb

Instance Method Summary collapse

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