Sha256: a06615587dd01e3d4ec115d331ef9cddca73e8dbff3dcf7599d65d5f69d96654

Contents?: true

Size: 962 Bytes

Versions: 8

Compression:

Stored size: 962 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) ? 304 : 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

8 entries across 8 versions & 1 rubygems

Version Path
alephant-broker-3.18.0 lib/alephant/broker/response/asset.rb
alephant-broker-3.17.0 lib/alephant/broker/response/asset.rb
alephant-broker-3.16.2 lib/alephant/broker/response/asset.rb
alephant-broker-3.16.1 lib/alephant/broker/response/asset.rb
alephant-broker-3.16.0 lib/alephant/broker/response/asset.rb
alephant-broker-3.15.2 lib/alephant/broker/response/asset.rb
alephant-broker-3.15.1 lib/alephant/broker/response/asset.rb
alephant-broker-3.15.0 lib/alephant/broker/response/asset.rb