Sha256: 2e953a26e2732d86b011686d191dc875ff02d63a626bca559b39975abd8adcef

Contents?: true

Size: 487 Bytes

Versions: 3

Compression:

Stored size: 487 Bytes

Contents

module Comable
  class Variant < ActiveRecord::Base
    module Quantifier
      def total_quantity
        if track_inventory?
          stocks.to_a.sum(&:quantity)
        else
          Float::INFINITY
        end
      end

      def can_supply?(required = 1)
        quantity >= required || backorderable?
      end

      # TODO: Implement
      def track_inventory?
        true
      end

      # TODO: Implement
      def backorderable?
        false
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
comable-core-0.7.1 app/models/comable/variant/quantifier.rb
comable-core-0.7.0 app/models/comable/variant/quantifier.rb
comable-core-0.7.0.beta2 app/models/comable/variant/quantifier.rb