Sha256: d0dac96322bff7f5bc6ee92c7854d1e3754745a1b2a183585793de698b1df4b7

Contents?: true

Size: 983 Bytes

Versions: 1

Compression:

Stored size: 983 Bytes

Contents

require "alephant/logger"

module Alephant
  module Broker
    module Response
      class Asset < Base
        include Logger

        def initialize(component, request_env)
          @component = component

          @status = self.class.component_not_modified(@component.headers, request_env) ? NOT_MODIFIED_STATUS_CODE : component.status

          super(@status, component.content_type, request_env)

          @headers.merge!(@component.headers)
        end

        def setup
          @content = @component.content
          log if @component.is_a? Component
        end

        private

        def batched
          @component.batch_id.nil? ? "" : "batched"
        end

        def details
          c = @component
          "#{c.id}/#{c.options}/#{c.headers} #{batched} #{c.options}"
        end

        def log
          logger.metric "BrokerResponse#{status}"
          logger.info "Broker: Component loaded! #{details} (200)"
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
alephant-broker-3.14.0 lib/alephant/broker/response/asset.rb