Class: BraintreeRails::MerchantAccount

Inherits:
Object
  • Object
show all
Includes:
Model
Defined in:
lib/braintree_rails/merchant_account.rb

Instance Method Summary collapse

Methods included from Model

included

Instance Method Details

#add_errors(validation_errors) ⇒ Object



22
23
24
25
# File 'lib/braintree_rails/merchant_account.rb', line 22

def add_errors(validation_errors)
  propagate_errors_to_associations(extract_errors(validation_errors))
  super(validation_errors)
end

#attributes_for(action) ⇒ Object



33
34
35
# File 'lib/braintree_rails/merchant_account.rb', line 33

def attributes_for(action)
  super.merge(individual_attributes).merge(business_attributes).merge(funding_attributes)
end

#business_attributesObject



41
42
43
# File 'lib/braintree_rails/merchant_account.rb', line 41

def business_attributes
  business.present? ? {:business => business.attributes_for(:as_association)} : {}
end

#funding_attributesObject



45
46
47
# File 'lib/braintree_rails/merchant_account.rb', line 45

def funding_attributes
  funding.present? ? {:funding => funding.attributes_for(:as_association)} : {}
end

#individual_attributesObject



37
38
39
# File 'lib/braintree_rails/merchant_account.rb', line 37

def individual_attributes
  individual.present? ? {:individual => individual.attributes_for(:as_association)} : {}
end

#propagate_errors_to_associations(validation_errors) ⇒ Object



27
28
29
30
31
# File 'lib/braintree_rails/merchant_account.rb', line 27

def propagate_errors_to_associations(validation_errors)
  [individual, business, funding].each do |association|
    association.add_errors(validation_errors) if association && errors
  end
end