app/models/piggybak/tax_method.rb in piggybak-0.1.1 vs app/models/piggybak/tax_method.rb in piggybak-0.2.0
- old
+ new
@@ -1,7 +1,14 @@
module Piggybak
class TaxMethod < ActiveRecord::Base
+
+ # klass_enum requires the ShippingCalculator subclasses to be loaded
+ shipping_calcs_path = File.expand_path("../tax_calculator", __FILE__)
+ Dir.glob(shipping_calcs_path + "**/*.rb").each do |subclass|
+ ActiveSupport::Dependencies.require_or_load subclass
+ end
+
has_many :tax_method_values, :dependent => :destroy
alias :metadata :tax_method_values
validates_presence_of :description
validates_presence_of :klass
@@ -17,11 +24,10 @@
end
end
end
def klass_enum
- #TODO: Troubleshoot use of subclasses here instead
- [Piggybak::TaxCalculator::FlatRate]
+ Piggybak::TaxCalculator.subclasses
end
def self.calculate_tax(object)
total_tax = 0