Class: PaymentDetails

Inherits:
Object
  • Object
show all
Defined in:
lib/payment_details.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(payment, params) ⇒ PaymentDetails

Returns a new instance of PaymentDetails.



4
5
6
7
8
# File 'lib/payment_details.rb', line 4

def initialize(payment, params)
  self.payment = payment
  self.params = params
  self.errors = []
end

Instance Attribute Details

#errorsObject

Returns the value of attribute errors.



2
3
4
# File 'lib/payment_details.rb', line 2

def errors
  @errors
end

#paramsObject

Returns the value of attribute params.



2
3
4
# File 'lib/payment_details.rb', line 2

def params
  @params
end

#paymentObject

Returns the value of attribute payment.



2
3
4
# File 'lib/payment_details.rb', line 2

def payment
  @payment
end

Instance Method Details

#saveObject



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/payment_details.rb', line 10

def save
  if payment.
    errors << "Payment Details can be submitted only once."
  else
    payment.validate_bank_details = true
    unless payment.update_attributes(params)
      errors << payment.errors.full_messages.to_sentence
    end
  end
  errors.empty?
end