Sha256: a3cc4d8ce375d1add8f47efbf59ee6e329ce77ad6b3d5c3f0f83477ef87688d5

Contents?: true

Size: 527 Bytes

Versions: 2

Compression:

Stored size: 527 Bytes

Contents

module Troo
  module API
    class Responder
      include Virtus.value_object

      values do
        attribute :body, String
        attribute :code, String
      end

      class << self
        def build(response)
          new(response).build
        end
      end

      def build
        ok? ? Response.new(attributes) : ErrorResponse.new(attributes)
      end

      private

      def ok?
        code == '200'
      end
    end

    class Response < Responder; end
    class ErrorResponse < Responder; end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
troo-0.0.10 lib/troo/api/response.rb
troo-0.0.9 lib/troo/api/response.rb