Class: TaxRate

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/tax_rate.rb

Class Method Summary collapse

Class Method Details

.match(address) ⇒ Object

Searches all possible TaxRates and returns the Zone which represents the most appropriate match (if any.) To be considered for a match, the Zone must include the supplied address. If multiple matches are found, the Zone with the highest rate will be returned. This method will return nil if no match is found.



13
14
15
# File 'app/models/tax_rate.rb', line 13

def self.match(address)
  TaxRate.all.select { |rate| rate.zone.include? address }
end