Module: SuperGood::SolidusTaxjar::CalculatorHelper
- Extended by:
- ActiveSupport::Concern
- Included in:
- TaxCalculator, TaxRateCalculator
- Defined in:
- lib/super_good/solidus_taxjar/calculator_helper.rb
Instance Method Summary collapse
- #cache ⇒ Object
- #exception_handler ⇒ Object
- #incomplete_address?(address) ⇒ Boolean
- #taxable_address?(address) ⇒ Boolean
Instance Method Details
#cache ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/super_good/solidus_taxjar/calculator_helper.rb', line 22 def cache if !Rails.env.test? Rails.cache.fetch( cache_key, expires_in: SuperGood::SolidusTaxjar.cache_duration ) { yield } else yield end end |
#exception_handler ⇒ Object
33 34 35 |
# File 'lib/super_good/solidus_taxjar/calculator_helper.rb', line 33 def exception_handler SuperGood::SolidusTaxjar.exception_handler end |
#incomplete_address?(address) ⇒ Boolean
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/super_good/solidus_taxjar/calculator_helper.rb', line 6 def incomplete_address?(address) return true if address.is_a?(::Spree::Tax::TaxLocation) [ address.address1, address.city, address.state&.abbr || address.state_name, address.zipcode, address.country&.iso ].any?(&:blank?) end |
#taxable_address?(address) ⇒ Boolean
18 19 20 |
# File 'lib/super_good/solidus_taxjar/calculator_helper.rb', line 18 def taxable_address?(address) SuperGood::SolidusTaxjar.taxable_address_check.call(address) end |