Class: Textus::Action::Get

Inherits:
Base
  • Object
show all
Defined in:
lib/textus/action/get.rb

Class Method Summary collapse

Methods inherited from Base

inherited, proposal_from

Methods included from Contract::DSL

#arg, #cli, #cli_stdin, #contract, #contract?, #summary, #surfaces, #verb, #view

Class Method Details

.call(container:, call:, key:) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/textus/action/get.rb', line 16

def self.call(container:, call:, key:)
  envelope = container.compositor.read(key)
  return Failure(code: :not_found, message: "no entry at #{key}") unless envelope

  entry = container.manifest.resolver.resolve(key).entry
  file_stat = Textus::Port::Storage::FileStat.new
  Success(envelope.with(freshness: freshness_evaluator(container, call, file_stat).verdict(entry)))
end

.freshness_evaluator(container, call, file_stat) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/textus/action/get.rb', line 25

def self.freshness_evaluator(container, call, file_stat)
  Textus::Core::Freshness::Evaluator.new(
    manifest: container.manifest,
    file_stat: file_stat,
    clock: call,
  )
end