Sha256: e276c2314c9e30e269a868cfa0fad6c6bb9bb1ed733d988f514de0f80f163347
Contents?: true
Size: 1.77 KB
Versions: 6
Compression:
Stored size: 1.77 KB
Contents
require 'react/server_rendering/environment_container' require 'react/server_rendering/manifest_container' require 'react/server_rendering/webpacker_manifest_container' module Hyperstack module Internal module Component module Rails module ServerRendering class HyperTestAssetContainer def find_asset(logical_path) ::Rails.cache.read(logical_path) end end class HyperAssetContainer def initialize @ass_containers = [] if assets_precompiled? @ass_containers << React::ServerRendering::ManifestContainer.new if React::ServerRendering::ManifestContainer.compatible? else @ass_containers << React::ServerRendering::EnvironmentContainer.new if ::Rails.application.assets end if React::ServerRendering::WebpackerManifestContainer.compatible? @ass_containers << React::ServerRendering::WebpackerManifestContainer.new end @ass_containers << HyperTestAssetContainer.new if ::Rails.env.test? end def find_asset(logical_path) @ass_containers.each do |ass| begin asset = ass.find_asset(logical_path) return asset if asset && asset != '' rescue next # no asset found, try the next container end end raise "No asset found for #{logical_path}, tried: #{@ass_containers.map { |c| c.class.name }.join(', ')}" end private def assets_precompiled? !::Rails.application.config.assets.compile end end end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems