Sha256: d18b5f4bbcc2ff3f961f23a43971fa097c4a6c6eb7337cae1141950daf7ad4ee

Contents?: true

Size: 652 Bytes

Versions: 4

Compression:

Stored size: 652 Bytes

Contents

module OCErrorDemo
  class WithoutContract
    include Flows::Plugin::OutputContract
  end

  class WithContract
    include Flows::Plugin::OutputContract

    success_with :ok do
      hash_of(
        x: Integer,
        y: Integer
      )
    end

    def call(result)
      result
    end
  end

  class << self
    include Flows::Result::Helpers

    def no_contract
      WithoutContract.new
    end

    def contract_error
      WithContract.new.call(ok(z: 100))
    end

    def status_error
      WithContract.new.call(ok(:unexpeted_status, x: 1, y: 2))
    end

    def result_type_error
      WithContract.new.call(z: 100)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
flows-0.6.0 bin/errors_cli/oc_error_demo.rb
flows-0.5.1 bin/errors_cli/oc_error_demo.rb
flows-0.5.0 bin/errors_cli/oc_error_demo.rb
flows-0.4.0 bin/errors_cli/oc_error_demo.rb