Sha256: 21524075c9bdfe8eeffaf271dc8036c89f28e3d509d9e49db6a526d2a65c9b48

Contents?: true

Size: 947 Bytes

Versions: 3

Compression:

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

          @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

3 entries across 3 versions & 1 rubygems

Version Path
alephant-broker-3.12.0 lib/alephant/broker/response/asset.rb
alephant-broker-3.11.0 lib/alephant/broker/response/asset.rb
alephant-broker-3.10.2 lib/alephant/broker/response/asset.rb