Class: Textus::Write::Mv

Inherits:
Object
  • Object
show all
Extended by:
Contract::DSL
Defined in:
lib/textus/write/mv.rb

Instance Method Summary collapse

Methods included from Contract::DSL

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

Constructor Details

#initialize(container:, call:) ⇒ Mv

‘call` already returns a wire hash; identity response.



20
21
22
23
24
25
# File 'lib/textus/write/mv.rb', line 20

def initialize(container:, call:)
  @container    = container
  @call         = call
  @manifest     = container.manifest
  @events       = container.events
end

Instance Method Details

#call(old_key, new_key, dry_run: false) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/textus/write/mv.rb', line 27

def call(old_key, new_key, dry_run: false)
  old_res, new_res = prepare(old_key, new_key)
  return dry_run_result(old_key, new_key, old_res, new_res) if dry_run

  ensure_uid!(old_key, old_res.entry)
  envelope = writer.move(
    from_key: old_key, to_key: new_key,
    new_mentry: new_res.entry
  )
  publish_renamed(old_key, new_key, envelope)
  success_result(old_key, new_key, old_res, new_res, envelope)
end