Sha256: 478e5d38c959f2a6bb6b820b3af9487be5129068452682f3270b30643ff9190d

Contents?: true

Size: 520 Bytes

Versions: 4

Compression:

Stored size: 520 Bytes

Contents

# frozen_string_literal: true

require "active_support/string_inquirer"

module Haku
  class Result
    def initialize(status, payload)
      @status = ActiveSupport::StringInquirer.new(status.to_s)
      @payload = payload

      return unless @payload.is_a?(Hash)

      @payload.each_key do |key|
        define_singleton_method(key) { @payload[key] }
      end
    end

    def result
      @payload
    end

    def success?
      @status.success?
    end

    def failure?
      @status.failure?
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
haku-1.5.0 lib/haku/result.rb
haku-1.4.0 lib/haku/result.rb
haku-1.3.1 lib/haku/result.rb
haku-1.3.0 lib/haku/result.rb