Class: Pay::PaymentMethod
- Inherits:
-
ApplicationRecord
- Object
- ApplicationRecord
- Pay::PaymentMethod
- Defined in:
- app/models/pay/payment_method.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.find_by_processor_and_id(processor, processor_id) ⇒ Object
20 21 22 |
# File 'app/models/pay/payment_method.rb', line 20 def self.find_by_processor_and_id(processor, processor_id) joins(:customer).find_by(processor_id: processor_id, pay_customers: {processor: processor}) end |
.pay_processor_for(name) ⇒ Object
24 25 26 |
# File 'app/models/pay/payment_method.rb', line 24 def self.pay_processor_for(name) "Pay::#{name.to_s.classify}::PaymentMethod".constantize end |
Instance Method Details
#make_default! ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'app/models/pay/payment_method.rb', line 32 def make_default! return if default? payment_processor.make_default! customer.payment_methods.update_all(default: false) update!(default: true) end |
#payment_processor ⇒ Object
28 29 30 |
# File 'app/models/pay/payment_method.rb', line 28 def payment_processor @payment_processor ||= self.class.pay_processor_for(customer.processor).new(self) end |