Sha256: a13812ed4cb3c1af04e85b758f9ab074f4e2b927344b5d6d6a762e1eaabb3d73

Contents?: true

Size: 918 Bytes

Versions: 34

Compression:

Stored size: 918 Bytes

Contents

module Workarea
  class Admin::VariantViewModel < ApplicationViewModel
    delegate :msrp, :on_sale, :on_sale?, :discountable,
      :discountable?, :tax_code, :sell_price, to: :pricing

    def pricing
      @pricing ||= Pricing::Sku.find_or_create_by(id: sku)
    end

    def inventory
      @inventory ||= Inventory::Sku.find_or_create_by(id: sku)
    end

    def available_inventory
      inventory.available
    end

    def detail_1_name
      details_array.first.try(:first)
    end

    def detail_1_value
      details_array.first.try(:second)
    end

    def detail_2_name
      details_array.second.try(:first)
    end

    def detail_2_value
      details_array.second.try(:second)
    end

    def detail_3_name
      details_array.third.try(:first)
    end

    def detail_3_value
      details_array.third.try(:second)
    end

    private

    def details_array
      details.to_a
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
workarea-admin-3.4.45 app/view_models/workarea/admin/variant_view_model.rb
workarea-admin-3.4.44 app/view_models/workarea/admin/variant_view_model.rb
workarea-admin-3.4.43 app/view_models/workarea/admin/variant_view_model.rb
workarea-admin-3.4.42 app/view_models/workarea/admin/variant_view_model.rb
workarea-admin-3.4.41 app/view_models/workarea/admin/variant_view_model.rb
workarea-admin-3.4.40 app/view_models/workarea/admin/variant_view_model.rb
workarea-admin-3.4.39 app/view_models/workarea/admin/variant_view_model.rb
workarea-admin-3.4.38 app/view_models/workarea/admin/variant_view_model.rb
workarea-admin-3.4.37 app/view_models/workarea/admin/variant_view_model.rb
workarea-admin-3.4.36 app/view_models/workarea/admin/variant_view_model.rb
workarea-admin-3.4.35 app/view_models/workarea/admin/variant_view_model.rb
workarea-admin-3.4.34 app/view_models/workarea/admin/variant_view_model.rb
workarea-admin-3.4.33 app/view_models/workarea/admin/variant_view_model.rb
workarea-admin-3.4.32 app/view_models/workarea/admin/variant_view_model.rb
workarea-admin-3.4.31 app/view_models/workarea/admin/variant_view_model.rb
workarea-admin-3.4.30 app/view_models/workarea/admin/variant_view_model.rb
workarea-admin-3.4.29 app/view_models/workarea/admin/variant_view_model.rb
workarea-admin-3.4.28 app/view_models/workarea/admin/variant_view_model.rb
workarea-admin-3.4.27 app/view_models/workarea/admin/variant_view_model.rb
workarea-admin-3.4.26 app/view_models/workarea/admin/variant_view_model.rb