Sha256: 2259f896b374f191ab208c8c5ace7bb0bed8ff04150e9a6d311abdeee9c8b1d8

Contents?: true

Size: 786 Bytes

Versions: 5

Compression:

Stored size: 786 Bytes

Contents

module SubZero
  class Message
    module Validations

      def validate_response! request
        broker_reply  = type == 'BRO'
        service_reply = type == 'REP' && subtype == request.sid

        unless broker_reply || service_reply
          fail Socket::Error, "unexpected result type: #{type}, " +
                              "subtype: #{subtype}. " + to_s
        end

        unless rid == request.rid
          fail Socket::Error, "rid mismatch. sent: #{request.rid}, " +
                              "received: #{rid}. " + to_s
        end

        unless verb == request.verb && response?
          fail Socket::Error, "reply verb mismatch: #{verb}, " +
                              "status: #{status}. " + to_s
        end

        true
      end

    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
sub_zero-0.0.9 lib/sub_zero/message/validations.rb
sub_zero-0.0.8 lib/sub_zero/message/validations.rb
sub_zero-0.0.7 lib/sub_zero/message/validations.rb
sub_zero-0.0.6 lib/sub_zero/message/validations.rb
sub_zero-0.0.5 lib/sub_zero/message/validations.rb