Sha256: c246a092936f6211bf62631145438d29e443bfec0250b5aff86892389ad311b1

Contents?: true

Size: 610 Bytes

Versions: 2

Compression:

Stored size: 610 Bytes

Contents

# frozen_string_literal: true

class PgExport
  module ValueObjects
    class Result
      attr_reader :value

      def initialize(value = nil)
        @value = value
      end
    end

    class Success < Result
      def success
        value
      end

      def bind
        yield
      end

      def on_success
        yield value

        self
      end

      def on_failure
        self
      end
    end

    class Failure < Result
      def bind
        self
      end

      def on_success
        self
      end

      def on_failure
        yield value

        self
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pg_export-1.0.0 lib/pg_export/value_objects/result.rb
pg_export-1.0.0.rc8 lib/pg_export/value_objects/result.rb