Sha256: 836cdf232d91edbbda82f60ffc9a996b2a65c7c9a73e7165b76debd013f55d7e

Contents?: true

Size: 811 Bytes

Versions: 1

Compression:

Stored size: 811 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

      private

      def config
        @config
      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.1 lib/alephant/broker/models/response_factory.rb