Sha256: a49ed817c6896a4f010d5593af474a9a87108fcda6cbbfb61b4410e5295ad186

Contents?: true

Size: 775 Bytes

Versions: 5

Compression:

Stored size: 775 Bytes

Contents

module ShipCompliant
  class ErrorResult < Struct.new(:error)

    # Gets the error code as an integer.
    #
    #   puts "ERROR ##{error.code}" #=> 404
    def code
      error[:code].to_i
    end

    # Gets the key of the item with an error.
    #
    #   puts error.key #=> 'ORDER-123'
    def key
      error[:key]
    end

    # Gets the error message.
    #
    #   puts "ERROR: #{error.message}" #=> 'I don't think it's a good idea,
    #   Yogi'
    def message
      error[:message]
    end

    # The object type that had the error.
    #
    #   puts error.target #=> 'SalesOrder'
    def target
      error[:target]
    end

    # The type of error that occured.
    #
    #   puts error.type #=> 'Validation'
    def type
      error[:type]
    end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ship_compliant-0.2.1 lib/ship_compliant/error_result.rb
ship_compliant-0.2.0 lib/ship_compliant/error_result.rb
ship_compliant-0.1.2 lib/ship_compliant/error_result.rb
ship_compliant-0.1.1 lib/ship_compliant/error_result.rb
ship_compliant-0.1.0 lib/ship_compliant/error_result.rb