Class: Spree::Calculator::TieredFlatRate

Inherits:
Spree::Calculator show all
Defined in:
app/models/spree/calculator/tiered_flat_rate.rb

Instance Method Summary (collapse)

Methods inherited from Spree::Calculator

#available?, calculators, description, #description, register, #to_s

Methods inherited from Base

display_includes, #initialize_preference_defaults, page, preference

Methods included from Preferences::Preferable

#default_preferences, #defined_preferences, #get_preference, #has_preference!, #has_preference?, #preference_default, #preference_type, #set_preference

Instance Method Details

- (Object) compute(object)



19
20
21
22
# File 'app/models/spree/calculator/tiered_flat_rate.rb', line 19

def compute(object)
  _base, amount = preferred_tiers.sort.reverse.detect{ |b, _| object.amount >= b }
  amount || preferred_base_amount
end