lib/appfuel/handler/base.rb in appfuel-0.5.8 vs lib/appfuel/handler/base.rb in appfuel-0.5.9

- old
+ new

@@ -39,10 +39,17 @@ result = create_response(result) unless response?(result) result end + def run!(inputs = {}, container = Dry::Container.new) + result = run(inputs, container) + fail_handler!(result) if result.failure? + + result.ok + end + def error(*args) response_handler.error(*args) end def ok(value = nil) @@ -55,9 +62,17 @@ def create_response(data) response_handler.create_response(data) end + def fail_handler!(response) + raise create_handler_failure(response) + end + + def create_handler_failure(response) + title = "#{container_class_path} Failed:" + HandlerFailure.new(title, response) + end end attr_reader :data def initialize(container = Dry::Container.new)