app/models/piggybak/payment_method.rb in piggybak-0.1.1 vs app/models/piggybak/payment_method.rb in piggybak-0.2.0
- old
+ new
@@ -1,18 +1,23 @@
module Piggybak
class PaymentMethod < ActiveRecord::Base
+
+ # klass_enum requires the ShippingCalculator subclasses to be loaded
+ shipping_calcs_path = File.expand_path("../payment_calculator", __FILE__)
+ Dir.glob(shipping_calcs_path + "**/*.rb").each do |subclass|
+ ActiveSupport::Dependencies.require_or_load subclass
+ end
+
has_many :payment_method_values, :dependent => :destroy
alias :metadata :payment_method_values
accepts_nested_attributes_for :payment_method_values, :allow_destroy => true
validates_presence_of :klass
validates_presence_of :description
def klass_enum
- #TODO: Troubleshoot use of subclasses here instead
- [Piggybak::PaymentCalculator::AuthorizeNet,
- Piggybak::PaymentCalculator::Fake]
+ Piggybak::PaymentCalculator.subclasses
end
validates_each :payment_method_values do |record, attr, value|
if record.klass
payment_method = record.klass.constantize