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
21 22 23 |
# File 'app/models/pay/payment_method.rb', line 21 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
25 26 27 |
# File 'app/models/pay/payment_method.rb', line 25 def self.pay_processor_for(name) "Pay::#{name.to_s.classify}::PaymentMethod".constantize end |
Instance Method Details
#make_default! ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'app/models/pay/payment_method.rb', line 33 def make_default! return if default? payment_processor.make_default! customer.payment_methods.update_all(default: false) update!(default: true) end |
#payment_processor ⇒ Object
29 30 31 |
# File 'app/models/pay/payment_method.rb', line 29 def payment_processor @payment_processor ||= self.class.pay_processor_for(customer.processor).new(self) end |