Class: Spree::Calculator::TieredFlatRate
- Inherits:
-
Spree::Calculator
- Object
- ActiveRecord::Base
- Base
- Spree::Calculator
- Spree::Calculator::TieredFlatRate
- Defined in:
- app/models/spree/calculator/tiered_flat_rate.rb
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Spree::Calculator
#available?, calculators, #description, register, #to_s
Methods inherited from Base
Methods included from Preferences::Preferable
#clear_preferences, #default_preferences, #defined_preferences, #get_preference, #has_preference!, #has_preference?, #preference_default, #preference_type, #set_preference
Class Method Details
.description ⇒ Object
17 18 19 |
# File 'app/models/spree/calculator/tiered_flat_rate.rb', line 17 def self.description Spree.t(:tiered_flat_rate) end |
Instance Method Details
#compute(object) ⇒ Object
21 22 23 24 |
# File 'app/models/spree/calculator/tiered_flat_rate.rb', line 21 def compute(object) base, amount = preferred_tiers.sort.reverse.detect{ |b,_| object.amount >= b } amount || preferred_base_amount end |