Class: PaymentDetails
- Inherits:
-
Object
- Object
- PaymentDetails
- Defined in:
- lib/payment_details.rb
Instance Attribute Summary collapse
-
#errors ⇒ Object
Returns the value of attribute errors.
-
#params ⇒ Object
Returns the value of attribute params.
-
#payment ⇒ Object
Returns the value of attribute payment.
Instance Method Summary collapse
-
#initialize(payment, params) ⇒ PaymentDetails
constructor
A new instance of PaymentDetails.
- #save ⇒ Object
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
#errors ⇒ Object
Returns the value of attribute errors.
2 3 4 |
# File 'lib/payment_details.rb', line 2 def errors @errors end |
#params ⇒ Object
Returns the value of attribute params.
2 3 4 |
# File 'lib/payment_details.rb', line 2 def params @params end |
#payment ⇒ Object
Returns the value of attribute payment.
2 3 4 |
# File 'lib/payment_details.rb', line 2 def payment @payment end |
Instance Method Details
#save ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/payment_details.rb', line 10 def save if payment.details_submitted? errors << "Payment Details can be submitted only once." else payment.validate_bank_details = true unless payment.update_attributes(params) errors << payment.errors..to_sentence end end errors.empty? end |