Sha256: 6f429bada6fff1e488e37ae6accf1f22567687014e230850b9f4e31cda7cc037

Contents?: true

Size: 495 Bytes

Versions: 34

Compression:

Stored size: 495 Bytes

Contents

module Workarea
  module Admin
    module FeaturedProductsViewModel
      def featured_products
        @featured_products ||=
          begin
            models = Catalog::Product.any_in(id: model.product_ids).to_a

            results = model.product_ids.map do |id|
              tmp = models.detect { |m| m.id == id }
              next unless tmp.present?
              Admin::ProductViewModel.new(tmp)
            end

            results.compact
          end
      end
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
workarea-admin-3.4.25 app/view_models/workarea/admin/featured_products_view_model.rb
workarea-admin-3.4.24 app/view_models/workarea/admin/featured_products_view_model.rb
workarea-admin-3.4.23 app/view_models/workarea/admin/featured_products_view_model.rb
workarea-admin-3.4.22 app/view_models/workarea/admin/featured_products_view_model.rb
workarea-admin-3.4.21 app/view_models/workarea/admin/featured_products_view_model.rb
workarea-admin-3.4.20 app/view_models/workarea/admin/featured_products_view_model.rb
workarea-admin-3.4.19 app/view_models/workarea/admin/featured_products_view_model.rb
workarea-admin-3.4.18 app/view_models/workarea/admin/featured_products_view_model.rb
workarea-admin-3.4.17 app/view_models/workarea/admin/featured_products_view_model.rb
workarea-admin-3.4.16 app/view_models/workarea/admin/featured_products_view_model.rb
workarea-admin-3.4.15 app/view_models/workarea/admin/featured_products_view_model.rb
workarea-admin-3.4.14 app/view_models/workarea/admin/featured_products_view_model.rb
workarea-admin-3.4.13 app/view_models/workarea/admin/featured_products_view_model.rb
workarea-admin-3.4.12 app/view_models/workarea/admin/featured_products_view_model.rb