Sha256: 53f24aeb3315be4b6673cfb95f590aca73ce3875a7ea8517091702c2695c90ec

Contents?: true

Size: 545 Bytes

Versions: 2

Compression:

Stored size: 545 Bytes

Contents

# frozen_string_literal: true

module Motor
  class IconsController < ApiBaseController
    CACHE_STORE = ActiveSupport::Cache::MemoryStore.new(coder: ActiveSupport::Cache::NullCoder)

    def index
      data = CACHE_STORE.fetch('icons') do
        Motor::Assets.icons.map do |icon|
          svg = Motor::Assets.load_asset("icons/#{icon}", gzip: !Motor.development?)
          svg = ActiveSupport::Gzip.decompress(svg) unless Motor.development?

          [icon, svg]
        end
      end

      render json: { data: data }
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
motor-admin-0.1.51 app/controllers/motor/icons_controller.rb
motor-admin-0.1.50 app/controllers/motor/icons_controller.rb