Class: Textus::Handlers::Write::PutEntry

Inherits:
Object
  • Object
show all
Defined in:
lib/textus/handlers/write/put_entry.rb

Instance Method Summary collapse

Constructor Details

#initialize(container:) ⇒ PutEntry

Returns a new instance of PutEntry.



5
6
7
# File 'lib/textus/handlers/write/put_entry.rb', line 5

def initialize(container:)
  @container = container
end

Instance Method Details

#call(command, call) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/textus/handlers/write/put_entry.rb', line 9

def call(command, call)
  Textus::Manifest::Data.validate_key!(command.key)
  mentry = @container.manifest.resolver.resolve(command.key).entry

  writer = Store::Entry::Writer.from(container: @container, call: call)
  envelope = writer.put(
    command.key,
    mentry: mentry,
    payload: Textus::Value::Payload.new(
      meta: command.meta,
      body: command.body,
      content: command.content,
    ),
    if_etag: command.if_etag,
  )
  Value::Result.success(envelope)
end