Class: Motor::IconsController

Inherits:
ApiBaseController show all
Defined in:
app/controllers/motor/icons_controller.rb

Constant Summary collapse

CACHE_STORE =
ActiveSupport::Cache::MemoryStore.new

Instance Method Summary collapse

Methods included from CurrentAbility

#current_ability

Methods included from CurrentUserMethod

#current_user

Instance Method Details

#indexObject


9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/controllers/motor/icons_controller.rb', line 9

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

      [icon.split('/').last, svg]
    end
  end

  render json: { data: data }
end