Class: Calculator::QuantityBucket
- Inherits:
-
Advanced
- Object
- Advanced
- Calculator::QuantityBucket
- Defined in:
- app/models/calculator/quantity_bucket.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#compute(object) ⇒ Object
as object we always get line items, as calculable we have Coupon, ShippingMethod.
Class Method Details
.description ⇒ Object
2 3 4 |
# File 'app/models/calculator/quantity_bucket.rb', line 2 def self.description I18n.t("quantity_bucket", :scope => :calculator_names) end |
.unit ⇒ Object
6 7 8 |
# File 'app/models/calculator/quantity_bucket.rb', line 6 def self.unit I18n.t(:qty) end |
Instance Method Details
#compute(object) ⇒ Object
as object we always get line items, as calculable we have Coupon, ShippingMethod
11 12 13 14 |
# File 'app/models/calculator/quantity_bucket.rb', line 11 def compute(object) total_quantity = object.line_items.map(&:quantity).sum get_rate(total_quantity) || self.preferred_default_amount end |