Sha256: e5300610a5f92ff33e0f464ba77534339aec102411a7068e23fd7aafc406512e

Contents?: true

Size: 1.46 KB

Versions: 1

Compression:

Stored size: 1.46 KB

Contents

# encoding: utf-8

module Substation
  class Response
    class Exception < self

      # Wraps response data and an exception not caught from a handler
      class Output
        include Equalizer.new(:data)

        # Return the data available when +exception+ was raised
        #
        # @return [Object]
        #
        # @api private
        attr_reader :data

        # Return the exception instance
        #
        # @return [Class<StandardError>]
        #
        # @api private
        attr_reader :exception

        # Initialize a new instance
        #
        # @param [Object] data
        #   the data available when +exception+ was raised
        #
        # @param [Class<StandardError>] exception
        #   the exception instance raised from a handler
        #
        # @return [undefined]
        #
        # @api private
        def initialize(data, exception)
          @data, @exception = data, exception
        end

        private

        # Tests wether +other+ is comparable using +comparator+
        #
        # @param [Symbol] comparator
        #   the operation used for comparison
        #
        # @param [Object] other
        #   the object to test
        #
        # @return [Boolean]
        #
        # @api private
        def cmp?(comparator, other)
          super && exception.class.public_send(comparator, other.exception.class)
        end
      end # class Output
    end # class Exception
  end # class Response
end # module Substation

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
substation-0.0.11 lib/substation/response/exception/output.rb