Class: ReactiveRuby::ServerRendering::HyperAssetContainer

Inherits:
Object
  • Object
show all
Defined in:
lib/reactive-ruby/server_rendering/hyper_asset_container.rb

Instance Method Summary collapse

Constructor Details

#initializeHyperAssetContainer

Returns a new instance of HyperAssetContainer.



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/reactive-ruby/server_rendering/hyper_asset_container.rb', line 14

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

Instance Method Details

#find_asset(logical_path) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/reactive-ruby/server_rendering/hyper_asset_container.rb', line 27

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