Sha256: 7818fc3548e2001e5bb1fc3f55590d8525fd2bf88383fcde10ad89148c353e93

Contents?: true

Size: 754 Bytes

Versions: 1

Compression:

Stored size: 754 Bytes

Contents

require 'alephant/broker/models/response'
require 'alephant/broker/models/response/asset_response'
require 'alephant/broker/models/response/batch_response'

module Alephant
  module Broker
    class ResponseFactory

      def initialize(config = nil)
        @config = config
      end

      def response_from(request)
          case request.type
          when :asset
            AssetResponse.new(request, @config)
          when :batch
            BatchResponse.new(request, @config).process
          when :status
            response(200)
          when :notfound
            response(404)
          when :error
            response(500)
          end
      end

      def response(status)
        Response.new(status)
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
alephant-broker-0.1.0 lib/alephant/broker/models/response_factory.rb