Sha256: c9c8f2fac940f3cc14d9b2f41e9793774b9f87044fcdf1dfb48402f076dd8d6f

Contents?: true

Size: 609 Bytes

Versions: 5

Compression:

Stored size: 609 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
          )
        end

        private

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
alephant-broker-3.0.1 lib/alephant/broker/request/asset.rb
alephant-broker-3.0.0 lib/alephant/broker/request/asset.rb
alephant-broker-2.1.3 lib/alephant/broker/request/asset.rb
alephant-broker-2.1.2 lib/alephant/broker/request/asset.rb
alephant-broker-2.1.1 lib/alephant/broker/request/asset.rb