Class: RailsDevtools::AssetConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_devtools/asset_config.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(providers) ⇒ AssetConfig

Returns a new instance of AssetConfig.



10
11
12
# File 'lib/rails_devtools/asset_config.rb', line 10

def initialize(providers)
  @providers = providers
end

Class Method Details

.findObject



5
6
7
8
# File 'lib/rails_devtools/asset_config.rb', line 5

def self.find
  providers = AssetProvider.new.list
  new(providers)
end

Instance Method Details

#helper_snippetObject



18
19
20
21
22
23
24
# File 'lib/rails_devtools/asset_config.rb', line 18

def helper_snippet
  if vite_rails?
    "vite_image_tag"
  else
    "image_tag"
  end
end

#implicit_pathObject



26
27
28
29
30
31
32
# File 'lib/rails_devtools/asset_config.rb', line 26

def implicit_path
  if vite_rails?
    ""
  else
    "images/"
  end
end

#pathsObject



14
15
16
# File 'lib/rails_devtools/asset_config.rb', line 14

def paths
  @paths ||= @providers.flat_map(&:paths)
end

#vite_rails?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/rails_devtools/asset_config.rb', line 34

def vite_rails?
  @providers.any? { |p| p.provider == :vite_rails }
end