Class: CompEx::Rails::AssetsController

Inherits:
ActionController::Base
  • Object
show all
Defined in:
lib/compex/rails/assets_controller.rb

Instance Method Summary collapse

Instance Method Details

#indexObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/compex/rails/assets_controller.rb', line 4

def index
  hashes = params.fetch(:h, "").split(",").map(&:strip)
  result = []

  hashes.each do |h|
    asset = ::CompEx::AssetProvider.provide(h)
    if asset
      result << {
        type: h.start_with?("j_") ? :script : :style,
        hash: h,
        source: asset
      }
    else
      result << nil
    end
  end

  render json: result
end