Class: Textus::Action::Put

Inherits:
WriteVerb show all
Extended by:
Contract::DSL
Defined in:
lib/textus/action/put.rb

Instance Method Summary collapse

Methods included from Contract::DSL

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

Methods inherited from Base

#args, inherited

Constructor Details

#initialize(key:, meta: nil, body: nil, content: nil, if_etag: nil) ⇒ Put

Returns a new instance of Put.



23
24
25
26
27
28
29
30
# File 'lib/textus/action/put.rb', line 23

def initialize(key:, meta: nil, body: nil, content: nil, if_etag: nil)
  super()
  @key = key
  @meta = meta
  @body = body
  @content = content
  @if_etag = if_etag
end

Instance Method Details

#call(container:, call:) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/textus/action/put.rb', line 32

def call(container:, call:)
  run_with_cascade(@key, container:, call:) do
    Textus::Manifest::Data.validate_key!(@key)
    mentry = container.manifest.resolver.resolve(@key).entry
    envelope = writer(container, call).put(
      @key,
      mentry: mentry,
      payload: Textus::Envelope::Writer::Payload.new(
        meta: @meta,
        body: @body,
        content: @content,
      ),
      if_etag: @if_etag,
    )

    envelope
  end
end