Class: Textus::Application::Write::Mv::Impl

Inherits:
Object
  • Object
show all
Defined in:
lib/textus/application/write/mv.rb

Instance Method Summary collapse

Constructor Details

#initialize(ctx:, caps:, reader:, writer:, hook_context:) ⇒ Impl

Returns a new instance of Impl.



15
16
17
18
19
20
21
22
23
# File 'lib/textus/application/write/mv.rb', line 15

def initialize(ctx:, caps:, reader:, writer:, hook_context:)
  @ctx          = ctx
  @manifest     = caps.manifest
  @events       = caps.events
  @authorizer   = caps.authorizer
  @reader       = reader
  @writer       = writer
  @hook_context = hook_context
end

Instance Method Details

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



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

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