class WarpEngine::ReleaseSerializer
Catalog view of a WarpEngine::Release: id, timestamps (see WarpEngine::TimestampFields), software id, version, the paths of the cartridge, source, HTML and docs assets, every asset as kind and path, and downloadCount. Asset paths are rewritten from the file container to /file/... URLs. The download_counts render option, a Hash of release id to count, saves a count query per release.
Constants
- FILE_PATH_TO
-
URL prefix that replaces the file container path in asset paths.
Public Class Methods
Source
# File app/serializers/warp_engine/release_serializer.rb, line 28 def self.asset_path(release, kind) asset = assets_of(release).find { |a| a.kind == kind } asset ? asset.path.gsub(file_path_from, FILE_PATH_TO) : "" end
Returns the /file/... path of the kind asset of release, or an empty String when it has none.
Source
# File app/serializers/warp_engine/release_serializer.rb, line 22 def self.assets_of(release) release.association(:release_assets).loaded? ? release.release_assets : release.release_assets.to_a end
Returns the kept release assets of release, using the loaded association when it is loaded.
Source
# File app/serializers/warp_engine/release_serializer.rb, line 16 def self.file_path_from "#{WarpEngine.config.file_container_path.chomp("/")}/" end
Returns the configured file container path with one trailing slash, the prefix rewritten to FILE_PATH_TO.