Method: Workarea::Storefront::ProductViewModel.wrap

Defined in:
app/view_models/workarea/storefront/product_view_model.rb

.wrap(model, options = {}) ⇒ Object



4
5
6
7
8
9
10
11
12
13
# File 'app/view_models/workarea/storefront/product_view_model.rb', line 4

def self.wrap(model, options = {})
  if model.is_a?(Enumerable)
    model.map { |m| wrap(m, options) }
  elsif Workarea.config.product_templates.include?(model.template.to_sym)
    view_model_class = "Workarea::Storefront::ProductTemplates::#{model.template.camelize}ViewModel"
    view_model_class.constantize.new(model, options)
  else
    new(model, options)
  end
end