Module: RailsTrade::PaymentMethod
- Extended by:
- ActiveSupport::Concern
- Included in:
- PaymentMethod
- Defined in:
- app/models/rails_trade/payment_method.rb
Defined Under Namespace
Modules: StripeMethod
Instance Method Summary collapse
- #account_types ⇒ Object
- #detect_repetition ⇒ Object
- #detective_save ⇒ Object
- #kind ⇒ Object
- #merge_from(other_id) ⇒ Object
- #repeat_results ⇒ Object
Instance Method Details
#account_types ⇒ Object
22 23 24 |
# File 'app/models/rails_trade/payment_method.rb', line 22 def account_types PaymentReference.pluck(:account_type).uniq end |
#detect_repetition ⇒ Object
35 36 37 38 39 40 41 |
# File 'app/models/rails_trade/payment_method.rb', line 35 def detect_repetition if self.persisted? self.class.unscoped.where.not(id: self.id).exists?(account_name: self.account_name, account_num: self.account_num) else self.class.unscoped.exists?(account_name: self.account_name, account_num: self.account_num) end end |
#detective_save ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'app/models/rails_trade/payment_method.rb', line 26 def detective_save if detect_repetition self.verified = false else self.verified = true end self.save end |
#kind ⇒ Object
60 61 62 |
# File 'app/models/rails_trade/payment_method.rb', line 60 def kind type.to_s.sub('Method', '').downcase end |
#merge_from(other_id) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'app/models/rails_trade/payment_method.rb', line 47 def merge_from(other_id) other = self.class.unscoped.find other_id self.class.transaction do other.payment_references.each do |payment_reference| payment_reference.payment_method_id = self.id # for callback, do not use update payment_reference.save end other.payment_references.reload other.destroy end end |
#repeat_results ⇒ Object
43 44 45 |
# File 'app/models/rails_trade/payment_method.rb', line 43 def repeat_results self.class.where.not(id: self.id).where(account_name: self.account_name, account_num: self.account_num) end |