Sha256: ce96fd8c53081c51f4aee7e5ebe73c7ecf619da90b74760e89a1c0960ffae9e3

Contents?: true

Size: 485 Bytes

Versions: 7

Compression:

Stored size: 485 Bytes

Contents

module Verbalize
  class Result
    def initialize(outcome:, value:)
      @outcome = outcome
      @value   = value
    end

    attr_reader :outcome

    def succeeded?
      !failed?
    end
    alias_method :success?, :succeeded?

    def failed?
      outcome == :error
    end
    alias_method :failure?, :failed?

    def to_ary
      [outcome, @value]
    end

    def value
      raise NotImplementedError, 'Subclasses must override Verbalize::Result#value'
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
verbalize-2.3.1 lib/verbalize/result.rb
verbalize-2.3.0 lib/verbalize/result.rb
verbalize-2.2.0 lib/verbalize/result.rb
verbalize-2.1.1 lib/verbalize/result.rb
verbalize-2.1.0 lib/verbalize/result.rb
verbalize-2.0.1 lib/verbalize/result.rb
verbalize-2.0.0 lib/verbalize/result.rb