Sha256: 722fa622590cbccbc57783d2718690ce00001f98d8b97b1a552cd1d1661ae378

Contents?: true

Size: 940 Bytes

Versions: 34

Compression:

Stored size: 940 Bytes

Contents

module Workarea
  module Pricing
    class CacheKey
      attr_reader :shippings
      attr_accessor :order
      delegate :pricing, :discounts, to: :@request

      def initialize(order, shippings, request)
        @order = order
        @shippings = shippings
        @request = request
      end

      def parts
        [
          pricing_key,
          discount_key,
          order_key,
          shipping_service_key,
          tax_key
        ]
      end

      def to_s
        Digest::SHA1.hexdigest(parts.join('/'))
      end

      private

      def pricing_key
        pricing.map(&:cache_key).join
      end

      def discount_key
        discounts.map(&:cache_key).join
      end

      def order_key
        order.cache_key
      end

      def shipping_service_key
        shippings.map(&:cache_key).join
      end

      def tax_key
        Workarea::Tax::Category.all.map(&:cache_key).join
      end
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

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