Sha256: 3e9c81e0282600b9be9a2d931c0b7ef0e1999500dadf188eb68f084f9f197430

Contents?: true

Size: 602 Bytes

Versions: 2

Compression:

Stored size: 602 Bytes

Contents

module Workarea
  decorate Pricing::Sku, with: :global_e do
    decorated do
      embeds_many :fixed_prices, class_name: "Workarea::GlobalE::FixedPrice", inverse_of: :pricing_sku
    end

    # Find the Fixed Price for this country currency combination, or for just the
    # currency otherwise returns nil
    #
    # @return [Workarea::GlobalE::FixedPrice, nil]
    #
    def fixed_price_for(currency_code:, country: nil)
      fixed_prices.find_by(currency_code: currency_code, country: country) rescue nil ||
        fixed_prices.find_by(currency_code: currency_code) rescue nil
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
workarea-global_e-1.3.0 app/models/workarea/pricing/sku.decorator
workarea-global_e-1.2.1 app/models/workarea/pricing/sku.decorator