Sha256: 081659f7050874a91ee8801ed2077d83b37b185c52d0a528861bb1456b0f909d
Contents?: true
Size: 1.06 KB
Versions: 3
Compression:
Stored size: 1.06 KB
Contents
module Workarea module Storefront class BlogEntryViewModel < ApplicationViewModel include DisplayContent def blog @blog ||= Storefront::BlogViewModel.new(model.blog) end def comments @comments ||= model.comments.approved.limit(100) end def products @products ||= Workarea::Storefront::ProductViewModel.wrap( Catalog::Product.find_ordered(product_ids) ) end def thumbnail_image_url find_asset(model.thumbnail_image).url(host: thumbnail_image_url_host) end # This ensures memoization happens def find_asset(id) @assets ||= {} return @assets[id.to_s] if @assets[id.to_s].present? @assets[id.to_s] = begin Content::Asset.find(id) rescue StandardError Content::Asset.placeholder end end private def thumbnail_image_url_host Rails.configuration.action_controller.asset_host end end end end
Version data entries
3 entries across 3 versions & 1 rubygems