Sha256: 88860070ff4828422f06488ff05c73c049483aa59f04fce44a4272ae4019197c

Contents?: true

Size: 515 Bytes

Versions: 4

Compression:

Stored size: 515 Bytes

Contents

module Workarea
  decorate Storefront::UserViewModel, with: :legacy_orders do
    def recent_orders
      super + legacy_orders
    end

    def legacy_orders
      Storefront::LegacyOrderViewModel.wrap(legacy_order_models)
    end

    def legacy_order_models
      return [] unless legacy_order_limit > 0

      LegacyOrder
        .for_email(model.email)
        .limit(legacy_order_limit)
    end

    def legacy_order_limit
      Workarea.config.recent_order_count - recent_order_models.size
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
workarea-legacy_orders-2.0.3 app/view_models/workarea/storefront/user_view_model.decorator
workarea-legacy_orders-2.0.2 app/view_models/workarea/storefront/user_view_model.decorator
workarea-legacy_orders-2.0.1 app/view_models/workarea/storefront/user_view_model.decorator
workarea-legacy_orders-2.0.0 app/view_models/workarea/storefront/user_view_model.decorator