lib/umwelt/command/convey.rb in umwelt-0.1.1 vs lib/umwelt/command/convey.rb in umwelt-0.2

- old
+ new

@@ -1,16 +1,13 @@ # frozen_string_literal: true module Umwelt::Command - class Convey - include Hanami::Interactor - # TODO: change to dry-rb transaction here + class Convey < Base + expose :written_paths - expose :result - def call(phase_id:, semantic:, source:, target:) - @result = imprint( + @written_paths = imprint( tree(source, phase_id), target, semantic ) end private @@ -27,58 +24,49 @@ ) ) end def imprint(tree, target, semantic) - result = Umwelt::Tree::Imprint.new(tree, location: target).call(semantic) - if result.success? - result.written_paths - else - error! result.errors - end + prove( + Umwelt::Tree::Imprint + .new(tree, location: target) + .call(semantic) + ).written_paths end def tree_fill(fragments) Umwelt::Tree::Fill.new.call(fragments) end def aggregate_history(episodes) - result = Umwelt::History::Aggregate.new.call(episodes) - if result.success? - result.fragments - else - error! result.errors - end + prove( + Umwelt::History::Aggregate + .new + .call(episodes) + ).fragments end def follow_history(continuity, source) - result = Umwelt::History::Follow - .new(path: source) - .call(continuity) - if result.success? - result.episodes - else - error! result.errors - end + prove( + Umwelt::History::Follow + .new(path: source) + .call(continuity) + ).episodes end def trace_history(history, phase_id) - result = Umwelt::History::Trace.new.call(history, phase_id) - if result.success? - result.continuity - else - error! result.errors - end + prove( + Umwelt::History::Trace + .new + .call(history, phase_id) + ).continuity end def restore_history(source) - restored = Umwelt::History::File::Restore - .new(path: source) - .call - if restored.success? - restored.struct - else - error! "Cannot restore history from '#{source}': #{restored.errors}" - end + prove( + Umwelt::History::File::Restore + .new(path: source) + .call + ).struct end end end