Module: FileHandlers

Defined in:
app/lib/file_handlers.rb

Defined Under Namespace

Classes: Assimp, BambuStudio, Base, CrealityPrint, Cura, ElegooSlicer, F3d, FlockXr, GcodeThumbnailExtractor, IframeTag, ImageTag, Lychee, OrcaSlicer, PrusaSlicer, Rouge, Slic3rFamily, SuperSlicer, Three, VideoTag

Constant Summary collapse

ALL_HANDLERS =
[]

Class Method Summary collapse

Class Method Details

.handlers_for(environment:, mime_type:) ⇒ Object



4
5
6
7
8
9
10
11
12
# File 'app/lib/file_handlers.rb', line 4

def self.handlers_for(environment:, mime_type:)
  Rails.cache.fetch("FileHandlers_handlers_for_#{environment}_#{mime_type}", expires_in: 1.hour) do
    Rails.logger.debug { "CACHE MISS for FileHandlers_handlers_for_#{environment}_#{mime_type}" }
    ALL_HANDLERS # rubocop:disable Pundit/UsePolicyScope
      .select { it.const_get(:ENVIRONMENTS).include? environment }
      .select { it.can_load? mime_type }
      .sort { |a, b| b&.priority <=> a&.priority }
  end
end