Sha256: 0f3e5f2d58c4d9f839357932f3980278a20226a498dd164f760dde67f5f783ad

Contents?: true

Size: 827 Bytes

Versions: 2

Compression:

Stored size: 827 Bytes

Contents

require "alephant/logger"
require "alephant/broker/errors/invalid_asset_id"

module Alephant
  module Broker
    module Request
      class Asset
        include Logger

        attr_accessor :component

        def initialize(component_factory, env = nil)
          return if env.nil?
          @component = component_factory.create(
            component_id(env.path),
            nil,
            env.options
          )
        rescue InvalidAssetId
          logger.metric "InvalidAssetId"
          logger.error(
            method: 'Broker.Request.Asset.initialize',
            message: 'Exception raised (InvalidAssetId)'
          )
        end

        private

        def component_id(path)
          path.split("/")[2] || (raise InvalidAssetId.new "No Asset ID specified")
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
alephant-broker-3.19.1 lib/alephant/broker/request/asset.rb
alephant-broker-3.19.0 lib/alephant/broker/request/asset.rb