Module: Shippinglogic::FedEx::Validation
- Included in:
- Service
- Defined in:
- lib/shippinglogic/fedex/validation.rb
Overview
This module is more for application integration, so you can do something like:
tracking = fedex.tracking
if tracking.valid?
# render a successful response
else
# do something with the errors: fedex.errors
end
Instance Method Summary collapse
-
#errors ⇒ Object
Just an array of errors that were encounted if valid? returns false.
-
#valid? ⇒ Boolean
Allows you to determine if the request is valid or not.
Instance Method Details
#errors ⇒ Object
Just an array of errors that were encounted if valid? returns false.
13 14 15 |
# File 'lib/shippinglogic/fedex/validation.rb', line 13 def errors @errors ||= [] end |
#valid? ⇒ Boolean
Allows you to determine if the request is valid or not. All validation is delegated to the FedEx services, so what this does is make a call to FedEx and rescue any errors, then it puts those error into the ‘errors’ array.
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/shippinglogic/fedex/validation.rb', line 20 def valid? begin target true rescue Error => e errors.clear self.errors << e. false end end |