Sha256: cb22caafb52fae501f1b0d7e3547d236d653e374872624a380ca81698d087a15

Contents?: true

Size: 830 Bytes

Versions: 9

Compression:

Stored size: 830 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(:name => "BrokerRequestAssetInvalidAssetId", :unit => "Count", :value => 1)
          logger.warn 'Broker.Request.Asset.initialize: 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

9 entries across 9 versions & 1 rubygems

Version Path
alephant-broker-3.5.0 lib/alephant/broker/request/asset.rb
alephant-broker-3.4.1 lib/alephant/broker/request/asset.rb
alephant-broker-3.4.0 lib/alephant/broker/request/asset.rb
alephant-broker-3.3.2 lib/alephant/broker/request/asset.rb
alephant-broker-3.3.1 lib/alephant/broker/request/asset.rb
alephant-broker-3.3.0 lib/alephant/broker/request/asset.rb
alephant-broker-3.2.0 lib/alephant/broker/request/asset.rb
alephant-broker-3.1.1 lib/alephant/broker/request/asset.rb
alephant-broker-3.1.0 lib/alephant/broker/request/asset.rb